delivered the opinion of the Court.
In this appeal, we must construe Code § 56-161 and determine *1029whether it is applicable in the present case and, if so, to what extent. In Southern Railway v. Boy, 221 Va. 1022, 277 S.E.2d 172 (1981), the companion case argued with the present case and this day decided, we held that a landowner whose land lies on only one side of a railroad right-of-way may not invoke the provisions of the statute to require a railroad company to repair a bridge which it had previously constructed as part of a wagonway across the right-of-way.
In the present case, Ferna Darnell, Sylvia Darnell, and Ann Darnell Gordon (collectively, the Darnells) filed a petition in the trial court against Southern Railway Company and Virginia and Southwestern Railway Company (collectively, the Railways), to require the Railways to repair a bridge affording access to their premises on the south side of the railroad right-of-way. The petition alleged that the land of the Darnells lay on both sides of the right-of-way, that the Railways had constructed and maintained the bridge across Little Moccasin Creek, that a substantial portion of the bridge was within the right-of-way, that the bridge had fallen into disrepair, and that the Railways had refused requests made by the Darnells to repair it. Petitioners sought the appointment of three disinterested persons as a board of commissioners pursuant to Code § 56-16 to determine whether the bridge should be repaired.
The Railways filed a demurrer to the petition on the ground, inter alia, that they were under no statutory or contractual duty to make the desired repairs. After this demurrer and the demurrer in the companion case had been filed, the trial court considered the cases jointly. On May 22, 1974, the trial judge notified counsel that before he ruled on the demurrer he desired that evidence be taken to determine whether the Darnells owned any land on the north side of the Railways’ right-of-way.2 Pursuant to this request, sharply conflicting evi*1030dence was taken by depositions. Over objection by the Railways, there was considerable evidence adduced by the Darnells that the right-of-way passed “through” the Darnells’ land. The evidence established that the Darnells’ father, their predecessor in title, owned a tract of land through which the Railways’ right-of-way passed prior to 1932. In that year, the Commonwealth acquired by condemnation title to a strip of the Darnell land 80 feet in width on the north side of the right-of-way. Subsequently, a public highway was constructed on the strip. Witnesses for the Darnells testified that they understood the Railways’ right-of-way was 25-feet-wide, leaving a narrow piece of land owned by the Darnells on the north side between the right-of-way and the public highway. Witnesses for the Railways testified that the right-of-way was 50-feet-wide, leaving no land owned by the Darnells north of it.
On the basis of the pleadings and the evidence the trial court overruled the demurrer. The Railways then filed an answer to the petition denying that the Darnells owned land on the north side of the right-of-way, asserting that the wagonway was used by the Darnells to go, not from one part of their land to the other, but to the public road, and denying that Code § 56-16 required the Railways to construct or repair the bridge from the Darnells’ land to the road. Without hearing any evidence, the trial court, over the Railways’ objection, entered an order on July 14, 1975, ruling that the Darnells were entitled to require the Railways to keep the wagonway in repair and appointing three persons as a board of commissioners under Code § 56-16 to view the property, “hear such evidence as either of the parties may desire to offer” and determine whether the bridge was in need of repairs “and should be repaired by the defendants”. The Commissioners were to report their decision in writing to the court.
The Board of Commissioners convened, viewed the bridge, and heard evidence. Expressly reserving their objection to the entry of the order appointing the Commissioners, the Railways cross-examined witnesses for the Darnells who were called to testify to the condition of the bridge. The Railways further requested that the Commissioners determine the width of the Railways’ right-of-way at the Darnell property, and determine whether the Darnells owned property north of the right-of-way, how much of the bridge was on the right-of-way, and whether the Railways should repair the bridge, and if so, how much of the bridge.
At the conclusion of the presentation of evidence by the Darnells, the Railways moved to strike the evidence as insufficient to show that the Darnells owned land that came within the protection of the statute, and noted that the ruling of the trial court had been merely *1031on demurrer. The Darnells asserted that the trial court had decided all issues except the state of repair of the bridge. Without waiving their objection, the Railways then introduced evidence on the status of the Darnells’ land. One witness, referring to a map showing the Railways’ right-of-way, testified that the Darnells owned no land north of the right-of-way. The other witness, a land surveyor, testified that according to his survey the Darnells owned a strip five-eighths of an inch wide on the north side. The Commissioners, disregarding the Railways’ request for other findings, reported in writing only that the bridge and wagonway were in need of repair and that the repairs should be made “by Southern Railway”. Exceptions to the report were filed by the Railways.
A hearing on the exceptions was conducted by the trial court, with a different judge presiding, his predecessor having retired. The court, ruling that all relevant issues, other than the question whether the bridge was in need of repairs, had been determined by the order entered on July 14, 1975, declined to review the earlier ruling. The court found that there was evidence to support the Commissioners’ report and entered a final order on October 27, 1978, overruling the exceptions and directing the Railways to repair the bridge.
On appeal, the Railways first contend that the trial court erred in overruling their demurrer. We do not agree. The petition alleged that the Railways’ right-of-way passed through the Darnells’ land, and this allegation, which the demurrer admitted as true for the purpose of having the court rule on the demurrer, stated a cause of action under Code § 56-16. Southern Railway v. Anderson, 203 Va. 991, 993, 128 S.E.2d 429, 431 (1962); Gaulding v. Virginian Railway Co., 121 Va. 19, 21, 92 S.E. 832, 833 (1917).
The substantive provisions of this statute were first enacted in 1837 as a part of the general regulations for the incorporation of railroad companies. Acts 1836-7, c. 118, § 16. In the Code of 1849, the provisions were extended to corporations generally in § 22 of Chapter 56 as follows:
“For every person, through whose land the road or canal of a company passes, it shall provide proper wagon ways across the road or canal, from one part of the said land to the other, and keep such ways in good repair.”
It is apparent that the purpose of the statute is to afford relief to a landowner through whose land a railroad is constructed and maintained so that the landowner may have access from his land on *1032one side of the railroad to his land on the other side. See Hurt v. Southern Railway, 207 Va. 60, 64, 147 S.E.2d 777, 780 (1966); Pennsylvania R. Co. v. Black, 175 Va. 256, 265, 8 S.E.2d 291, 295 (1940). The statute imposes the duty to repair as well as the duty to construct wagonways. And, where the railroad passes through a tract of land, the duty to repair continues after the duty to construct has been fulfilled. Gaulding, supra, 121 Va. at 21, 92 S.E. at 833.
Gaulding, however, does not stand for the proposition advanced by the Darnells, that once the obligation to construct has been met, the duty to repair continues thereafter in perpetuity regardless of changes in the status of the land through which the railroad originally passed. Rather, if a landowner whose land is divided by a railroad divests himself of all his land on one side of the right-of-way, he may not thereafter require the railroad company to maintain or repair the wagonway previously constructed to afford him access from one part of the land to the other. The railroad no longer passes “through” his land, and, thus, he no longer has need of the wagonway for the only purpose recognized in the statute. Moreover, a landowner may not bring himself piecemeal within the intendment of the statute by first acquiring land on one side of a railroad right-of-way and then subsequently acquiring land on the other side.
We reject the contention of the Railways that any duty to repair should be limited to that portion of the bridge that is within their right-of-way. The statute is remedial and must be given a reasonable construction to effectuate its purpose, Pennsylvania R. Co. v. Black, supra, 175 Va. at 265, 8 S.E.2d at 295, quoting Adams v. Tidewater Ry. Co. 107 Va. 798, 801, 60 S.E. 129, 129-30 (1908); Lanford v. Va. Air Line Ry. Co., 113 Va. 68, 77, 73 S.E. 566, 570 (1912).
The Railways rely upon a Texas case, Hays v. Texarkana & Ft. Smith Ry., 87 S.W.2d 1106 (Tex. Civ. App. 1935), holding that the statutory duty of a railroad to maintain crossings at public streets included the duty to maintain a viaduct, but only so much of the viaduct as was on the railroad right-of-way. To the contrary, we hold that where Code § 56-16 is applicable, the railroad company must construct and maintain an entire bridge that is part of a required wagonway, even if only a portion of the bridge is within the railroad right-of-way. Any other construction of the statute could relieve a railroad of a portion of the cost of acquiring its right-of-way at the expense of the very class of persons the statute is designed to protect. For example, in Adams the landowner proceeded under the statute after the railroad company had acquired its right-of-way through the land in condemnation proceedings. Without the available statutory relief, the landowner *1033must necessarily have been entitled to a substantially greater award upon condemnation which divided his land and denied him access to a portion thereof. By providing wagonways the railroad company significantly reduces the damages for which it otherwise would be answerable, and the landowner should not be required to assume any of the cost of installing or maintaining a facility for which the railroad is liable.
We also reject the Railways’ argument that the use of the birdge by the Darnells is now only for the purpose of ingress and egress to and from the public road and is not within the protection of the statute. If the railroad passed through the land and still continues to pass through, then the landowner is entitled to rely on the statute even if the chief purpose in using the wagonway has changed. That the wagonway is now primarily used to reach a public roadway does not terminate the railroad’s duty to maintain it if it is still necessary — albeit of secondary importance — in order for the landowner to get from one portion of his land to another. Therefore, so long as the railroad right-of-way continues to “pass through” the property of the landowner, and the landowner continues to use the wagonway to get from one part of his property to the other, other uses are irrelevant.
The crucial question in the present case, therefore, is whether the Darnells own a tract of land, divided by the Railways’ right-of-way, that has continued without interruption to lie on each side of and adjacent to the right-of-way. As the moving parties, the Darnells had the burden of proving that they were entitled to invoke the statute. The allegations in their petition were sufficient to withstand a demurrer. But the Railways complain that they were never given a hearing before the trial court on the determinative question. We agree that the unusual requirement by the trial court that evidence be taken before a ruling on the demurrer would be made did not adequately apprise the Railways that they would not thereafter have a full hearing on the merits. Indeed, they sought without success to have the Commissioners consider additional evidence and make certain findings as to the status of the Darnells’ land. We hold, therefore, not only that it was improper to require the presentation of evidence prior to ruling on the demurrer, but that the trial court further erred in entering the order of July 14, 1975, without giving the Railways a hearing on the merits.
Finally, there is no authorization in Code § 56-16 for the procedure followed in this case. The statute provides in detail for the appointment of a board of commissioners to determine whether a requested wagonway should be constructed and if so at what location *1034and in what manner. No such provision is made for the appointment of commissioners to determine whether repairs to a wagonway should be made. We hold, therefore, that the trial court erred in appointing commissioners to determine whether the Railways were obligated to repair the bridge. It was the duty of the trial court to decide, after a full evidentiary hearing, whether the Darnells were entitled to require the Railways to maintain the bridge and, if so, whether the bridge was in need of repairs.
We will reverse the judgment of the trial court and remand the case for a new trial consistent with the views expressed herein.
Reversed and remanded.
Code § 56-16 provides in pertinent part:
§ 56-16. Wagonways to be constructed across roads, canals and other works; enforcement. — Every public service corporation, whose road, canal, or works passes through the lands of any person in this State, shall provide proper and suitable wagonways across such road, canal, or other works, from one part of such land to the other, and shall keep such ways in good repair. Such ways shall be constructed on the request of the landowner, in writing, made to any section master, agent, or employee of such company, having charge and supervision of the railroad, canal, or other works at that point, and shall designate the points at which the wagonways are desired; and if there be no section master, agent, or employee of such company, having charge or supervision of the railroad, canal, or other works at such point, then on the request of the landowner, in writing, made to the company, or any officer or director thereof. If the company fail or refuse for ten days after such request to construct wagonways of a convenient and proper character at the places designated, then the owner, having given ten days’ notice in writing, as aforesaid, may apply to the circuit court of the county or the corporation court of the city wherein such land is located for the appointment of three disinterested persons whose lands do not abut on such railroad, canal, or other works, who shall constitute a board of commissioners whose *1029duty it shall be to go upon the land and determine whether the wagonways asked for should be constructed. The decision of such board shall be in writing, and, if favorable to the landowner, it shall set forth the points at which the wagonways should be constructed, giving also a description of what should be done by the company to make a suitable and convenient way.
The effect of a demurrer is to admit as true all allegations that are well-pleaded. Burns v. Board of Supervisors, 218 Va. 625, 627, 238 S.E.2d 823, 824 (1977). Therefore, the only issue at the demurrer stage is whether the plaintiff has stated a cause of action. Votsis v. Ward’s Coffee Shop, 217 Va. 652, 654, 231 S.E.2d 236, 237 (1977). Without requesting the submission of evidence the trial court should have ruled on the demurrer on the basis of what was alleged in the petition. See Gaulding v. Virginian Railway Co., 121 Va. 19, 21-22, 92 S.E. 832, 833 (1917); Burks Pleading and Practice § 213 (4th ed. Boyd, 1952). Nevertheless, it appears from the record that neither the Darnells nor the Railways objected to the procedure required by the trial court.