The client HTML form element fits into the ExtraFormContent placeholder.
All in all, nested HTML forms are a nonissue—you just don’t use them. However, a common pitfall in ASP.NET development is that because of master pages you inadvertently end up with nested forms in an attempt to add a second innocent client HTML form.
Multiple Server
public partial class MultipleForms : System.Web.UI.Page
{
protected void Page_Load(Object sender, EventArgs e)
{
Title = "Welcome";
}
protected void Button1_Click(Object sender, EventArgs e)
{
Title = "Step 1";
step0.Visible = false;
step1.Visible = true;
}
protected void Button2_Click(Object sender, EventArgs e)
{
step0.Visible = true;
step1.Visible = false;
}
protected void Button3_Click(Object sender, EventArgs e)
{
Title = "Finalizing";
step1.Visible = false;
step2.Visible = true;
}
protected void Button4_Click(Object sender, EventArgs e)
{
Title = "Done";
step2.Visible = false;
Response.Write("
}
}
Figure 9-3. Mutually exclusive forms.
Multiple View and Wizards
If you’re targeting ASP.NET 2.0 or newer, you might not need to resort to the preceding trick to switch between forms. You find two new controls—MultiView and Wizard—ready for the job. The MultiView control employs logic nearly identical to that of multiple exclusive forms, except that it relies on panels rather than full forms.
The MultiView control allows you to define multiple and mutually exclusive HTML panels. The control provides an application programming interface (API) for you to toggle the visibility of the various panels and ensure that exactly one is active and visible at a time. The MultiView control doesn’t provide a built-in user interface. The Wizard control is just that—a MultiView control plus some wizard-like predefined user interface (UI) blocks. I’ll cover the Wizard control in great detail later in the chapter.
Cross-Page Postings