3.4. Simulating Multipage Forms
Problem
You want to create a form that appears, from
the
user’s prospective, to consist of multiple pages,
while keeping all of your code in one .aspx file
and the code-behind that accompanies it.
Solution
Create one ASP.NET page. Use panels to separate the HTML for each of
the “virtual” pages you wish to
display, and simulate a multipage form by enabling one panel at a
time. The output of a typical three-page form is shown in Figures
Figure 3-1 through Figure 3-3.
Example 3-13 through Example 3-15 show the .aspx and
code-behind files for an application that implements this solution.

Figure 3-1. Multipage form output (page 1)

Figure 3-2. Multipage form output (page 2)

Figure 3-3. Multipage form output (page 3)
Discussion
In classic ASP, a series of questions or prompts, such as those on a
survey or wizard, are typically implemented using multiple ASP pages
with each submitting to the next in turn. ASP.NET allows you to
submit a form to itself, which means that you have to rethink how to
implement a survey, wizard, or traditionally multipart form. The
solution we advocate involves defining multiple panels on a single
form with the ASP:Panel control, and showing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access