Adding a list of modes to the page (VB) : WebPartManager « WebPart « ASP.NET Tutorial

Home
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
ASP.NET Tutorial » WebPart » WebPartManager 
24.3.2.Adding a list of modes to the page (VB)
<%@ Page Language="VB"%>

<script runat="server">
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, _
       ByVal e As System.EventArgs)

      Dim wpDisplayMode As WebParts.WebPartDisplayMode = _
      Webpartmanager1.SupportedDisplayModes(DropDownList1.SelectedValue.ToString())
      Webpartmanager1.DisplayMode = wpDisplayMode
    End Sub

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
      For Each wpMode As WebPartDisplayMode In Webpartmanager1.SupportedDisplayModes            
            Dim modeName As String = wpMode.Name
            Dim dd_ListItem As ListItem = New ListItem(modeName, modeName)
            DropDownList1.Items.Add(dd_ListItem)
      Next
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Web Parts Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:WebPartManager ID="Webpartmanager1" Runat="server">
        </asp:WebPartManager>
        <table>
            <tr>
                <td colspan="2">
                    <h1>Web Page</h1>
                    <asp:WebPartZone ID="WebPartZone1" Runat="server" 
                     LayoutOrientation="Horizontal">
                        <ZoneTemplate>
                            <asp:Label ID="Label1" Runat="server" Text="Label" 
                             Title="Welcome to my web page!">
                             Welcome to the page!
                            </asp:Label>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td valign="top">
                    Select mode:
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                     AutoPostBack="True" 
                     OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">        
                    </asp:DropDownList>
                </td>
            </tr>
            <tr valign="top">
                <td>
                    <asp:WebPartZone ID="WebPartZone2" Runat="server">
                        <ZoneTemplate>
                            <asp:Image ID="Image1" Runat="server" 
                             ImageUrl="~/Images/Kids.jpg" Width="150px" 
                             Title="My Kids">
                            </asp:Image>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td>
                    <asp:WebPartZone ID="WebPartZone3" Runat="server">
                        <ZoneTemplate>
                            <asp:Calendar ID="Calendar1" Runat="server"
                             Title="Calendar">
                            </asp:Calendar>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
            </tr>
        </table>        
    </form>
</body>
</html>
24.3.WebPartManager
24.3.1.Adding a list of modes to the page (C#)
24.3.2.Adding a list of modes to the page (VB)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.