Web part with WebPartManager : WebPartManager « WebPart « ASP.Net

ASP.Net
1. ADO.net Database
2. Ajax
3. Asp Control
4. Collections
5. Components
6. Data Binding
7. Development
8. File Directory
9. HTML Control
10. Language Basics
11. Login Security
12. Mobile Control
13. Network
14. Page
15. Request
16. Response
17. Server
18. Session Cookie
19. Sitemap
20. Theme Style
21. User Control and Master Page
22. Validation by Control
23. Validation by Function
24. WebPart
25. WPF
26. 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 Tutorial
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 » WebPart » WebPartManager 
Web part with WebPartManager


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

<!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>Web Parts Sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:WebPartManager ID="WebPartManager1" runat="server">
        </asp:WebPartManager>
        <asp:RadioButtonList ID="RadioButtonList1" 
                             runat="server" 
                             AutoPostBack="True" 
                             OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
                             RepeatColumns="3">
            <asp:ListItem Selected="True">Browse</asp:ListItem>
            <asp:ListItem>Edit</asp:ListItem>
            <asp:ListItem>Catalog</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <table>
            <tr>
                <td>
                    <asp:WebPartZone ID="WebPartZone1" runat="server">
                        <ZoneTemplate>
                            <asp:Calendar ID="Calendar1" 
                                          runat="server" 
                                          DayNameFormat="Shortest" 
                                          Height="180px" 
                                          Width="200px">
                                <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
                                <SelectorStyle BackColor="Navy" />
                                <WeekendDayStyle BackColor="#FFFFCC" />
                                <OtherMonthDayStyle ForeColor="Gray" />
                                <TodayDayStyle BackColor="Navy" ForeColor="Black" />
                                <NextPrevStyle VerticalAlign="Bottom" />
                                <DayHeaderStyle BackColor="Navy" Font-Bold="True" Font-Size="7pt" />
                                <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
                            </asp:Calendar>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td>
                    <asp:WebPartZone ID="WebPartZone2" 
                                     runat="server" 
                                     BorderColor="Navy" 
                                     Font-Names="Verdana"
                                     Padding="6">
                        <PartChromeStyle BackColor="#EFF3FB" BorderColor="#D1DDF1" Font-Names="Verdana" ForeColor="Red" />
                        <MenuLabelHoverStyle ForeColor="#D1DDF1" />
                        <EmptyZoneTextStyle Font-Size="0.8em" />
                        <MenuLabelStyle ForeColor="White" />
                        <MenuVerbHoverStyle BackColor="#EFF3FB" 
                                            BorderColor="Navy" 
                                            BorderStyle="Solid"
                                            BorderWidth="1px" 
                                            ForeColor="Red" />
                        <HeaderStyle Font-Size="0.7em" 
                                     ForeColor="Navy" 
                                     HorizontalAlign="Center" />
                        <ZoneTemplate>
                            <asp:CheckBoxList ID="CheckBoxList1" runat="server">
                                <asp:ListItem>Red</asp:ListItem>
                                <asp:ListItem>Green</asp:ListItem>
                                <asp:ListItem>Blue</asp:ListItem>
                            </asp:CheckBoxList>
                        </ZoneTemplate>
                        <MenuVerbStyle BorderColor="#507CD1" 
                                       BorderStyle="Solid" 
                                       BorderWidth="1px" 
                                       ForeColor="White" />
                        <PartStyle Font-Size="0.8em" ForeColor="Red" />
                        <TitleBarVerbStyle Font-Size="0.6em" Font-Underline="False" ForeColor="White" />
                        <MenuPopupStyle BackColor="#507CD1" 
                                        BorderColor="Navy" 
                                        BorderWidth="1px" 
                                        Font-Names="Verdana"
                                        Font-Size="0.6em" />
                        <PartTitleStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.8em" ForeColor="White" />
                    </asp:WebPartZone>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:WebPartZone ID="WebPartZone3" runat="server" BorderColor="Navy" Font-Names="Verdana"
                        Padding="6">
                        <PartChromeStyle BackColor="#EFF3FB" BorderColor="#D1DDF1" Font-Names="Verdana" ForeColor="Red" />
                        <MenuLabelHoverStyle ForeColor="#D1DDF1" />
                        <EmptyZoneTextStyle Font-Size="0.8em" />
                        <MenuLabelStyle ForeColor="White" />
                        <MenuVerbHoverStyle BackColor="#EFF3FB" 
                                            BorderStyle="Solid"
                                            BorderWidth="1px" 
                                            ForeColor="Red" />
                        <HeaderStyle Font-Size="0.7em" ForeColor="Navy" HorizontalAlign="Center" />
                        <ZoneTemplate>
                            <asp:BulletedList ID="BulletedList1" runat="server">
                                <asp:ListItem>List</asp:ListItem>
                                <asp:ListItem>Of</asp:ListItem>
                                <asp:ListItem>Things</asp:ListItem>
                            </asp:BulletedList>
                        </ZoneTemplate>
                        <MenuVerbStyle BorderColor="#507CD1" 
                                       BorderStyle="Solid" 
                                       BorderWidth="1px" 
                                       ForeColor="White" />
                        <PartStyle Font-Size="0.8em" ForeColor="Red" />
                        <TitleBarVerbStyle Font-Size="0.6em" 
                                           Font-Underline="False" 
                                           ForeColor="White" />
                        <MenuPopupStyle BackColor="#507CD1" 
                                        BorderColor="Navy" 
                                        BorderWidth="1px" 
                                        Font-Names="Verdana"
                                        Font-Size="0.6em" />
                        <PartTitleStyle BackColor="#507CD1" 
                                        Font-Bold="True" 
                                        Font-Size="0.8em" 
                                        ForeColor="White" />
                    </asp:WebPartZone>
                </td>
                <td>
                    <asp:WebPartZone ID="WebPartZone4" 
                                     runat="server" 
                                     BorderColor="Navy" 
                                     Font-Names="Verdana"
                                     Padding="6">
                        <PartChromeStyle BackColor="#EFF3FB" 
                                         BorderColor="#D1DDF1" 
                                         Font-Names="Verdana" 
                                         ForeColor="Red" />
                        <MenuLabelHoverStyle ForeColor="#D1DDF1" />
                        <EmptyZoneTextStyle Font-Size="0.8em" />
                        <MenuLabelStyle ForeColor="White" />
                        <MenuVerbHoverStyle BackColor="#EFF3FB" 
                                            BorderColor="Navy" 
                                            BorderStyle="Solid"
                                            BorderWidth="1px" 
                                            ForeColor="Red" />
                        <HeaderStyle Font-Size="0.7em" 
                                     ForeColor="Navy" 
                                     HorizontalAlign="Center" />
                        <ZoneTemplate>
                            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                        </ZoneTemplate>
                        <MenuVerbStyle BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" ForeColor="White" />
                        <PartStyle Font-Size="0.8em" ForeColor="Red" />
                        <TitleBarVerbStyle Font-Size="0.6em" Font-Underline="False" ForeColor="White" />
                        <MenuPopupStyle BackColor="#507CD1" 
                                        BorderColor="Navy" 
                                        BorderWidth="1px" 
                                        Font-Names="Verdana"
                                        Font-Size="0.6em" />
                        <PartTitleStyle BackColor="#507CD1" 
                                        Font-Bold="True" 
                                        Font-Size="0.8em" ForeColor="White" />
                    </asp:WebPartZone>
                </td>
            </tr>
        </table>
    
    </div>
        <asp:CatalogZone ID="CatalogZone1" runat="server">
            <ZoneTemplate>
                <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
            </ZoneTemplate>
        </asp:CatalogZone>
        <asp:EditorZone ID="EditorZone1" runat="server">
        </asp:EditorZone>
    </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;

public partial class WebPartsSample : System.Web.UI.Page
{

  protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
  {
    if (this.RadioButtonList1.SelectedValue.ToLower() == "browse")
    {
      this.WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode;
    }
    else if (this.RadioButtonList1.SelectedValue.ToLower() == "edit")
    {
      this.WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;
    }
    else
    {
      this.WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
    }
  }
}

 
Related examples in the same category
1. Display Mode Menu
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.