Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Controls
 

Use the MultiView control to dynamically switch views in a page

<%@ Page language="C#"%> <script runat="server">    void Page_Load(object sender, EventArgs e)    {        Tables.ActiveViewIndex = Views.SelectedIndex;    } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>View controls</title> </head> <body>     <div id="pageContent">         <form id="Form1" runat="server">             <tr>             <td valign="top">             <asp:DropDownList Runat="server" ID="Views" AutoPostBack="true">                 <asp:ListItem Value="Employees" />                  <asp:ListItem Value="Products" />                  <asp:ListItem Value="Customers" />              </asp:DropDownList>             </td>             <td valign="top" style="border:solid 1px black;">             <asp:MultiView runat="server" id="Tables" ActiveViewIndex="0" >               <asp:View runat="server" id="Employees">                     <h1>Employees</h1>               </asp:View>               <asp:View runat="server" id="Products">                     <h1>Products</h1>                 </asp:View>                 <asp:View runat="server" id="Customers">                     <h1>Customers</h1>                 </asp:View>             </asp:MultiView>             </td>             </tr>         </form>     </div> </body> </html>