Minggu, 28 Juli 2013

How to use MultiView and View Control in ASP.NET

The MultiView Control
The MultiView control is a container for a group of view controls . It allows you to define a group of View controls , where each View control contains child controls . Your application can then render a specific View control based on specific criteria , such as user identity, user preferences, and information passed in a querystring parameter. The MultiView control is also used to create wizard . To allow user to navigate between View controls within a MultiView control, you can add a LinkButton or Button control to each View control.

Public properties of the MultiView Class
ActiveViewIndex : Obtains or set the index value of the active View control within a MultiView control.
EnableTheming : Obtains or sets a value showing whether themes apply to the MultiView control.
Views : Obtains the collections of view controls in the MultiView control.

Public Methods of the MultiView Class
GetActiveView : Obtains the current active View control within a MultiView control.
setActiveView : Sets the specified View control to the active view within a MultiView control.

Public Event of the MultiView Class
ActiveViewChnaged : Raised when the active View control of a multiView control changes between posts to the server.

The View Control 
The view control is a container for a group of controls . A View control must always be stored within a MultiView control. Only one View control can be defined as the active view within a MultiView control at a time. A view control can contain any type of controls, including other MultiView controls. A View control does not support any style properties . To apply styles to a View Control , You have to add one or more panel controls to the View controls. To allow users to navigate between multiple View controls within a MultiView control , you can add a LinkButton or Button control to each View Control.

Public Properties of the View Class
EnableTheming : Obtains or sets a value showing if themes apply to this controls or not.
Visible : Obtains or sets a value which indicates whether the  View control is visible.




<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
        MultiView1.Visible = true;
        MultiView1.SetActiveView(View1);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        MultiView1.Visible = true;
        MultiView1.SetActiveView(View2);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            font-size: larger;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <strong><span class="auto-style1">Select Buttons for birthday gift </span></strong>

    <div>
 
        <asp:Button ID="Button1" runat="server" Text="Gift 1" OnClick="Button1_Click" />&nbsp;
        <asp:Button ID="Button2" runat="server" Text="Gift 2" OnClick="Button2_Click" />
 
        <br />
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex ="0" Visible ="false">
            <asp:View ID="View1" runat ="server">
                <asp:Image ID="Image1" runat="server" Height="165px" ImageUrl="~/picture/images.jpg" Width="194px" />

            </asp:View>
            <asp:View ID="View2" runat ="server" >
                <asp:Image ID="Image2" runat="server" Height="165px" ImageUrl="~/picture/motorola droid.jpg" Width="191px" />

            </asp:View>
        </asp:MultiView>
 
    </div>
    </form>
</body>
</html>


Output
How to use MultiView and View Control in ASP.NET

How to use MultiView and View Control in ASP.NET

Tidak ada komentar:

Posting Komentar