Multiview Control
Previous | Home | Next |
The ASP.NET MultiView control can be used for virtually anything. Introduced in ASP.NET 2.0, the MultiView provides exactly that - multiple views on one page, with one view being displayed at a time. This provides a great advantage over Panels when trying to develop a multi-step process, as you are not required to set the visibility of each individual view for each step. Instead, you can just set the currently active view. All controls within each view will be accessible in the code-behind.
Multiview Control Design ************************************************************************ ******************* <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Multiview.aspx.cs" Inherits="_Default" %>********************************************************************* .CS Code ********************************************************************* ****** using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void but_Submit_Click(object sender, EventArgs e) { if (MultiView1.ActiveViewIndex == 0) { MultiView1.SetActiveView(View2); } else if (MultiView1.ActiveViewIndex == 1) { MultiView1.SetActiveView(View3); if (String.IsNullOrEmpty(fld_Name.Text)) { lit_Name.Text = "You did not enter your name. "; } else { lit_Name.Text = "Hi, " + fld_Name.Text + ". "; } } else if (MultiView1.ActiveViewIndex == 2) { MultiView1.SetActiveView(View1); } } } *********************************************************************Multiview
Previous | Home | Next |