Multiview Set Active View

The MultiView control is used together with a number of View controls to change the content presented to the website visitor.

Setting the active view shows only that block of code as visible on the web page. An example of its use is a page showing a table of items. Selecting an individual table row changes the page to show the details pertaining to the selected entry.

Panels can be used to achieve this, but it soon becomes cumbersome. Each panel requires its visibility to be set accordingly. The more steps built into the page the more panels which need to be handled, for example:

pnlList.Visible = False
pnlReview.Visible = True
pnlSummary.Visible = False

MultiViews simplify the disclosing of parts of the presentation according to the current step in the sequence. In place of setting the visibility for each of the panels a single call to set the required view hides all of the others and shows the requested one.

.ascx File

Below is an example MultiView  with three views, as described in the panels above.

The code is a part of the HTML from the .ascx file

<asp:MultiView ID="mltApplications" runat="server">
<asp:View ID="vewList" runat="server" >
:::
</asp:View>
<asp:View ID="vewReview" runat="server" >
:::
</asp:View>
<asp:View ID="vewSummary" runat="server" >
:::
</asp:View>
</asp:MultiView>

Code File

The following code examples illustrate selecting one of the views above, VewReview. The first line shows the declaration required for the MultiView and then secondly the call to set it. The corresponding definitions for VB.NET and C#, in the code file are:

VB.NET

Protected WithEvents mltApplications As System.Web.UI.WebControls.MultiView
:::
:::
mltApplications.SetActiveView("FindControl("vewReview"))

C#

protected global::System.Web.UI.WebControles.MultiView mltApplications;
:::
:::
View vewReview = findControl("vewReview") as View;
mltApplications.SetActiveView(vewReview);