O'Reilly logo

ASP.NET Cookbook by Geoffrey T. LeBlond, Michael A Kittel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Multipage form output (page 1)

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

Multipage form output (page 2)

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

Multipage form output (page 3)

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required