블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Category

Recent Post

Recent Comment

Archive

2009. 10. 28. 09:53 .Net Project/ASP.NET 3.5 Sp1
반응형

 
 
 1. WebPartManager 컨트롤을 가장 상단에 떨어 뜨려 놓는다 (필수)
 2. 3개의 영역에 각각 WebPartZone 컨트롤을 올려 놓도록 한다
 3. 각각의 영역에 Calendar 컨트롤을 떨어 뜨린다
 4. 각각의 영역에 Image 컨트롤을 떨어 뜨린다
 5. 각각의 영역에 Login 컨트롤을 떨어 뜨린다 
 6. 각각의 컨트롤에 Title="로그" 다음과 같이 속성 지정

 실행시 컨트롤을 닫았을 경우 다시 복원하기 위해서 사용
 7. 최상위 메뉴 옆에 드롭다운 리스트 추가 

<td colspan="3">메뉴<asp:DropDownList ID="DropDownList1" runat="server"

                    AutoPostBack="true"
                   onselectedindexchanged="DropDownList1_SelectedIndexChanged">

                    <asp:ListItem Value="0">Browse</asp:ListItem>

                    <asp:ListItem Value="1">Design</asp:ListItem>

                    <asp:ListItem Value="2">Catalog</asp:ListItem>

                </asp:DropDownList>

            </td>


 8. DropDownList 컨트롤에 Changed 이벤트 클릭을 잡는다. 

  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedValue == "0")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode; 
        }
        else if (this.DropDownList1.SelectedValue=="1")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode;
        }
        else if (this.DropDownList1.SelectedValue=="2")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
        }
    }
 9. Catalog Zone 컨트롤 추가  후 컨트롤안데 Page Catalog Zone 컨트롤 추가 완료
     (CatalogZon 컨트롤은 다른 zon 영역안에 추가 불가능 하다)
<asp:CatalogZone ID="CatalogZone1" runat="server">
         <ZoneTemplate>
             <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
         </ZoneTemplate>              
     </asp:CatalogZone>
 

 WebPart.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:WebPartManager ID="WebPartManager1" runat="server">
        </asp:WebPartManager>
   
    <table border="1">
        <tr>
            <td colspan
="3">메뉴<asp:DropDownList ID="DropDownList1" runat="server"
                    AutoPostBack="true" 
                      onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem Value="0">Browse</asp:ListItem>
                    <asp:ListItem Value="1">Design</asp:ListItem>
                    <asp:ListItem Value="2">Catalog</asp:ListItem>
               
</asp:DropDownList>
            </td>
        </tr>
       
         <tr>
            <td>
<asp:WebPartZone ID="WebPartZone1" runat="server">
                <ZoneTemplate>
                    <asp:Calendar ID="
Calendar1" runat="server"  Title="달력"></asp:Calendar>
                      
                </ZoneTemplate>
                </asp:WebPartZone>
                역1</td>
            <td>영<asp:WebPartZone ID="WebPartZone2" runat="server">
                <ZoneTemplate>
                    <asp:Image ID=
"Image1" runat="server" Title="로고" />
                </ZoneTemplate>
                </asp:WebPartZone>
                역2</td>
            <td><asp:WebPartZone ID="WebPartZone3" runat="server">
                <ZoneTemplate>
                    <asp:Login ID="
Login1" runat="server" Title="로그인">
                    </asp:Login>
                </ZoneTemplate>
                </asp:WebPartZone>

                역3</td>
               
        </tr>    
    </table>
     <asp:CatalogZone ID="
CatalogZone1" runat="server">
         <ZoneTemplate>
             <asp:PageCatalogPart ID
="PageCatalogPart1" runat="server" />
         </ZoneTemplate>
             
     </asp:CatalogZone>
   
    </div>
    </form>
</body>
</html>


 WebPart.aspx.Cs

using System;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

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

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedValue == "0")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode; 
        }
        else if (this.DropDownList1.SelectedValue=="1")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode;
        }
        else if (this.DropDownList1.SelectedValue=="2")
        {
            this.WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
        }
    }
}









반응형
posted by Magic_kit