MultiView and View Controls : MultiView « ASP.net Controls « ASP.NET Tutorial

ASP.NET Tutorial
1. ASP.Net Instroduction
2. Language Basics
3. ASP.net Controls
4. HTML Controls
5. Page Lifecycle
6. Response
7. Collections
8. Validation
9. Development
10. File Directory
11. Sessions
12. Cookie
13. Cache
14. Custom Controls
15. Profile
16. Configuration
17. LINQ
18. ADO.net Database
19. Data Binding
20. Ajax
21. Authentication Authorization
22. I18N
23. Mobile
24. WebPart
25. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.NET Tutorial » ASP.net Controls » MultiView 
3. 23. 5. MultiView and View Controls
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>MultiView & View Controls</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>MultiView & View Controls</h1>
     <br/>
       <asp:RadioButtonList AutoPostBack="True" ID="rblView" 
         OnSelectedIndexChanged="rblView_SelectedIndexChanged"
         RepeatDirection="Horizontal" runat="server">
         <asp:ListItem Value="-1">Nothing</asp:ListItem>
         <asp:ListItem Value="0" Selected="True">First</asp:ListItem>
         <asp:ListItem Value="1">Second</asp:ListItem>
         <asp:ListItem Value="2">Third</asp:ListItem>
         <asp:ListItem Value="3">Last</asp:ListItem>
       </asp:RadioButtonList>
       <br />
       Current Index: 
     <asp:Label ID="lblCurrentIndex" runat="server"></asp:Label>
     <br/>
       <asp:MultiView ID="MultiView1" runat="server" 
        ActiveViewIndex="0" 
        OnActiveViewChanged="MultiView1_ActiveViewChanged">
         <asp:View ID="vwFirst" runat="server" 
          OnActivate="ActivateView" 
          OnDeactivate="DeactivateView">
           <h2>
             First View
           </h2>
           <asp:TextBox ID="txtFirstView" runat="server"></asp:TextBox>
           <asp:Button CommandName="NextView" ID="btnNext1" runat="server" Text="Go To Next" />
           <asp:Button CommandArgument="vwLast" CommandName="SwitchViewByID" ID="btnLast" runat="server" Text="Go to Last" />
        </asp:View>
         <asp:View ID="vwSecond" runat="server" 
          OnActivate="ActivateView" 
          OnDeactivate="DeactivateView">
           <h2>
             Second View
          </h2>
           <asp:TextBox ID="txtSecondView" runat="server"></asp:TextBox>
           <asp:Button CommandName="NextView" ID="btnNext2" runat="server" Text="Go To Next" />
           <asp:Button CommandName="PrevView" ID="btnPrevious2" runat="server" Text="Go to Previous" />
         </asp:View>
         <asp:View ID="vwThird" runat="server" 
          OnActivate="ActivateView" 
          OnDeactivate="DeactivateView">
           <h2>
             Third View</h2>
          <br />
           <asp:Button CommandName="NextView" ID="btnNext3" runat="server" Text="Go To Next" />
           <asp:Button CommandName="PrevView" ID="btnPrevious3" runat="server" Text="Go to Previous" />
         </asp:View>
         <asp:View ID="vwLast" runat="server" 
          OnActivate="ActivateView" 
          OnDeactivate="DeactivateView">
           <h2>
             Last View
             </h2>
           <asp:Button CommandName="PrevView" ID="btnPrevious4" runat="server" Text="Go to Previous" />
           <asp:Button CommandArgument="0" CommandName="SwitchViewByIndex" ID="btnFirst" runat="server" Text="Go to First" />
         </asp:View>
       </asp:MultiView>
      <br />
      <br />
      First TextBox:  
      <asp:Label ID="lblFirstTextBox" runat="server" />
      <br />
      Second TextBox:  
      <asp:Label ID="lblSecondTextBox" runat="server" />
      <br />
      <br />
     <strong><span style="text-decoration: underline">
      View Activation History:</span></strong>
     <br />
     <asp:Label ID="lblViewActivation" runat="server" />
      
    
    </div>
    </form>
</body>
</html>

File: Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_PreRender(object sender, EventArgs e)
    {
     lblCurrentIndex.Text = MultiView1.ActiveViewIndex.ToString();
    }

  protected void rblView_SelectedIndexChanged(object sender, EventArgs e)
   {
     MultiView1.ActiveViewIndex = Convert.ToInt32(rblView.SelectedValue);
   }
   
  protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
   {
     lblFirstTextBox.Text = txtFirstView.Text;
     lblSecondTextBox.Text = txtSecondView.Text;

     rblView.SelectedIndex = MultiView1.ActiveViewIndex + 1;
   }

  protected void ActivateView(object sender, EventArgs e)
   {
     string str = lblViewActivation.Text;
     View v = (View)sender;
     str += "View " + v.ID + " activated <br/>";
     lblViewActivation.Text = str;
   }
   
  protected void DeactivateView(object sender, EventArgs e)
   {
     string str = lblViewActivation.Text;
     View v = (View)sender;
     str += "View " + v.ID + " deactivated <br/>";
     lblViewActivation.Text = str;
   }
 }
3. 23. MultiView
3. 23. 1. MultiView hides and display different areas of a page, useful to create a tabbed page
3. 23. 2. What is an asp:MultiView (C#)
3. 23. 3. Displaying a Multi-Part Form
3. 23. 4. Use the MultiView control to dynamically switch views in a page
3. 23. 5. MultiView and View Controls
3. 23. 6. Active index
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.