Wednesday 11 January 2012

MultiView Example in ASP.NET using C#





MultiView Example in ASP.NET using C#


 Default.aspx
----------------
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem Value="0">one</asp:ListItem>
            <asp:ListItem Value="1">two</asp:ListItem>
            <asp:ListItem Value="2">three</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <hr />
        <asp:MultiView ID="MultiView1" runat="server">
        <asp:View ID="one" runat=server>
        <h2>This is First Contain</h2>
        <br />
            <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
        <br />
            <asp:Button ID="Button1" runat="server" Text="Button" />
       
        </asp:View>
       
        <asp:View ID="two" runat=server>
        Name: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        City: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
       
            <asp:Button ID="Button2" runat="server" Text="Button" />
       
       
        </asp:View>
       
       <asp:View ID="third" runat=server>
           <asp:RadioButtonList ID="RadioButtonList1" runat="server">
               <asp:ListItem>Male</asp:ListItem>
               <asp:ListItem>Female</asp:ListItem>
           </asp:RadioButtonList>
           <br />
          
       </asp:View>
        </asp:MultiView>
    </div>
    </form>
</body>
</html>








 Default.aspx.cs
------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = Convert.ToInt16(DropDownList1.SelectedValue);
    }
}





demo of MultiView Example in ASP.NET using C#


Share This
Previous Post
Next Post

0 Comments: