Panel通過Loader方式,調用頁面作為內容加載。
其中,要注意的幾個關鍵點:
主頁面:
<ext:ResourceManager ID="ResourceManager1" runat="server"> </ext:ResourceManager> <ext:Panel ID="Panel1" runat="server" Title="Parent" Height="300" Width="500"> <Items> <ext:Button ID="Button1" runat="server" Text="Button1" OnDirectClick="btn1_Click"> </ext:Button> </Items> <Loader ID="Loader1" runat="server" Url="Child.aspx" Mode="Html" Scripts="true" /> <Buttons> <ext:Button ID="Button2" runat="server" Text="Button2" OnDirectClick="btn2_Click" /> </Buttons> </ext:Panel>
後台代碼:
protected void btn2_Click(object sender, DirectEventArgs e) { Panel1.Loader.Visible = false; Panel1.Update(); } protected void btn1_Click(object sender, DirectEventArgs e) { Panel1.Loader.Visible = true; Panel1.Update(); }
子頁面:
<ext:ResourceManager ID="ResourceManager1" runat="server" RenderScripts="None"> </ext:ResourceManager> <ext:Panel ID="Panel2" runat="server" Title="Child" Width="300" Height="185" Frame="true"> <Items> <ext:Label ID="Label2" runat="server" /> </Items> <Buttons> <ext:Button ID="btnChild" runat="server" Text="Submit [DirectEvent]"> <DirectEvents> <Click OnEvent="btnChild_Click" Url="Child.aspx" /> </DirectEvents> </ext:Button> <ext:Button ID="Button1" IDMode="Ignore" runat="server" Text="Submit [DirectMethod]"> <Listeners> <Click Handler="App.direct.ButtonClickChild({ url: 'Child.aspx' });" /> </Listeners> </ext:Button> </Buttons> </ext:Panel>
後台代碼:
protected void btnChild_Click(object sender, DirectEventArgs e) { this.Label2.Text = "Child [DirectEvent]: " + DateTime.Now.ToLongTimeString(); X.Msg.Alert("DirectEvent", "Child Button Clicked").Show(); } [DirectMethod] public void ButtonClickChild() { this.Label2.Text = "Child [DirectMethod]: " + DateTime.Now.ToLongTimeString(); X.Msg.Alert("DirectMethod", "Child Button Clicked").Show(); }