What is an asp:MultiView (C#) : 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. 2. What is an asp:MultiView (C#)
File: Default.aspx

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

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <tr>
                <td>
                    <asp:MultiView id="MultiView1" 
                                   runat="server" 
                                   ActiveViewIndex="0">
                        <asp:View ID="View1" 
                                  runat="server">
                                  Choose a foreground (textcolor:<br  />
                            <asp:DropDownList ID="lstForeColor" 
                                              runat="server" 
                                              AutoPostBack="True" 
                                              Height="22px"
                                              OnSelectedIndexChanged="ControlChanged" 
                                              Width="194px">
                            </asp:DropDownList><br  />
                            <br  />
                            Choose a background color:<br  />
                            <asp:DropDownList ID="lstBackColor" runat="server" AutoPostBack="True" Height="22px"
                                OnSelectedIndexChanged="ControlChanged" Width="194px">
                            </asp:DropDownList>
                            
                            <br />
                            
                            <asp:Button ID="cmdNext" runat="server" Text="Next >" CommandName="NextView" />
                            
                            </asp:View>
                            
                        <asp:View ID="View2" runat="server">
                            Choose a border style:<br  />
                            <asp:RadioButtonList ID="lstBorder" runat="server" AutoPostBack="True"
                                Height="59px" OnSelectedIndexChanged="ControlChanged" RepeatColumns="2" Width="177px">
                            </asp:RadioButtonList><br  />
                            <br  />
                            <asp:CheckBox ID="chkPicture" runat="server" AutoPostBack="True" OnCheckedChanged="ControlChanged"
                                Text="Add the Default Picture"  />
                                
                            <br />
                            <asp:Button ID="Button3" runat="server" Text="< Prev" CommandName="PrevView" />
                            <asp:Button ID="Button4" runat="server" Text="Next >" CommandName="NextView" />
                            
                                </asp:View>
                        <asp:View ID="View3" runat="server">
                            Choose a font name:<br  />
                            <asp:DropDownList ID="lstFontName" runat="server" AutoPostBack="True" Height="22px"
                                OnSelectedIndexChanged="ControlChanged" Width="194px">
                            </asp:DropDownList><br  />
                            <br  />
                            Specify a font size:<br  />
                            <asp:TextBox ID="txtFontSize" runat="server" AutoPostBack="True" OnTextChanged="ControlChanged"></asp:TextBox><br  />
                            <br  />
                            Enter the greeting text below:<br  />
                            <asp:TextBox ID="txtGreeting" runat="server" Height="85px" OnTextChanged="ControlChanged"
                                TextMode="MultiLine" Width="240px" AutoPostBack="True"></asp:TextBox>
                            
                            <br />
                            <asp:Button ID="Button1" runat="server" Text="< Prev" CommandName="PrevView" />
                            <asp:Button ID="Button2" runat="server" Text="Apply" />
                            
                        </asp:View>
                    </asp:MultiView>
                </td>
                <td >
                    <asp:Panel ID="pnlCard" runat="server" Height="445px" HorizontalAlign="Center" Style="z-index: 101;
                        Width="339px">
                        <br />
                        &nbsp;
                        <asp:Label ID="lblGreeting" runat="server" Height="150px" Width="272px"></asp:Label>
                        <asp:Image ID="imgDefault" runat="server" Height="160px" Visible="False" Width="212px" />
                    </asp:Panel>
                </td>
            </tr>
        </div>
        
    </form>
</body>
</html>


File: Default.aspx.cs



using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Drawing;
using System.ComponentModel;

public partial class MultiViewGreetingCardMaker : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string[] colorArray = Enum.GetNames(typeof(System.Drawing.KnownColor));
            lstBackColor.DataSource = colorArray;
            lstBackColor.DataBind();

            lstForeColor.DataSource = colorArray;
            lstForeColor.DataBind();
            lstForeColor.SelectedIndex = 34;
            lstBackColor.SelectedIndex = 163;

            System.Drawing.Text.InstalledFontCollection fonts;
            fonts = new System.Drawing.Text.InstalledFontCollection();
            foreach (FontFamily family in fonts.Families)
            {
                lstFontName.Items.Add(family.Name);
            }

            string[] borderStyleArray = Enum.GetNames(typeof(BorderStyle));
            lstBorder.DataSource = borderStyleArray;
            lstBorder.DataBind();

            lstBorder.SelectedIndex = 0;

            imgDefault.ImageUrl = "http://www.java2java.com/style/logo.png";
        }
    }
    protected void ControlChanged(Object sender, EventArgs e)
    {
        pnlCard.BackColor = Color.FromName(lstBackColor.SelectedItem.Text);
        lblGreeting.ForeColor = Color.FromName(lstForeColor.SelectedItem.Text);
        lblGreeting.Font.Name = lstFontName.SelectedItem.Text;
        try
        {
            if (Int32.Parse(txtFontSize.Text0)
            {
                lblGreeting.Font.Size = FontUnit.Point(Int32.Parse(txtFontSize.Text));
            }
            if (Int32.Parse(txtFontSize.Text0)
            {
                lblGreeting.Font.Size =
                    FontUnit.Point(Int32.Parse(txtFontSize.Text));
            }
        }catch{
        }
        TypeConverter cnvrt = TypeDescriptor.GetConverter(typeof(BorderStyle));
        pnlCard.BorderStyle = (BorderStyle)cnvrt.ConvertFromString(lstBorder.SelectedItem.Text);
        if (chkPicture.Checked == true)
        {
            imgDefault.Visible = true;
        }
        else
        {
            imgDefault.Visible = false;
        }
        lblGreeting.Text = txtGreeting.Text;
    }
}
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.