如何在ASP.NET中最大化webpart?

时间:2011-08-30 11:55:28

标签: c# custom-controls web-parts

我正在尝试在.net 3.5中创建类似iGoogle的页面

我已经编写了代码(在asp.net中)来动态地将usercontrols添加到2个webzones中.....非常简单的东西......

我现在想知道的是我如何单独最大化每个webzone,如果我点击标题栏上的o按钮它应该占据整个页面然后在最小化它应该回到其原始状态。(有点喜欢在iGoogle中发生的事情)

另外,如果你运行我正在粘贴的代码,你会看到在button_click它每次创建一个新的webzone ....我仍然无法想出如何更改控件形式'UNTITLED'的标题..

我继续说我是新手,完整的解释以及可执行的代码将非常棒:):)):))我不想使用预先打包的stustuff,如动态仪表板插件n喜欢.... :)

以下是我的.cs代码

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



    protected void Page_Load(object sender, EventArgs e) 
    { 
        //done nothing here as I am trying to get the funcionalities of the web part before implementing in the proper page. 
       //probably wrong so please correct me 
    } 



    //The basic idea is that once the page is complete, there will be a multiple check box list with a list of widgets.  
    //the ones which are checked will be added to the page in the zones.a very basic DASHBOARD so to say. 


    protected void btn1_Click(object sender, EventArgs e) 
    { 



        //Getting the usercontrol through my local path(placed it in the same folder, so file name was sufficient) 
        UserControl Test = (UserControl)LoadControl("Subtract.ascx"); 



        Test.ID = "test"; 


        GenericWebPart part1 = WebPartManager1.CreateWebPart(Test);//creating first webpart 
        UserControl Add = (UserControl)LoadControl("Test.ascx");//Adding second webcontrol 

        Add.ID = "Add"; 

        GenericWebPart part2 = WebPartManager1.CreateWebPart(Add); 


        //LoadControls(); 
        WebPartManager1.AddWebPart(part1, Zone1, 0);//adding to first webzone. 




        WebPartManager1.AddWebPart(part2, Zone2, 1);//adding to second webzone. 
        WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;//so that i can move the webparts around from one zone to another. 

        part1.Title.Equals("Zone1");//trying to change the title of the webparts, not working:( 

    } 


}

这是我的aspx代码:

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Process_Flow_Dashboard_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>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <table id="webTable1" runat="server" width="100%"> 
        <tr> 
            <td> 

                <asp:WebPartManager ID="WebPartManager1" runat="server" Personalization-Enabled="true"> 
                </asp:WebPartManager> 
                <asp:EditorZone ID="EditorZone1" runat="server"> 
                    <ZoneTemplate> 
                        <asp:AppearanceEditorPart ID="AppearanceEditorPart1" runat="server" /> 
                    </ZoneTemplate> 
            </asp:EditorZone> 
            </td> 

        </tr> 
        <tr> 
            <td> 
                <asp:Button ID="btn1" runat="server" Text="Button" OnClick="btn1_Click" /> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:WebPartZone ID="Zone1" runat="server" Width="100%" DisplayTitle="Zone 1"> 


                </asp:WebPartZone> 
            </td> 
            <td> 
                <asp:WebPartZone ID="Zone2" runat="server" Width="100%" Title="Zone 2"> 
                </asp:WebPartZone> 
            </td> 
        </tr> 
    </table> 
    </form> 
</body> 
</html>

0 个答案:

没有答案