Apr 03, 2012, 9:16 AM
[CLOSED] ComponentLoader with UserControl containing Ext.Net control with DirectMethods
Hi!
I have a question about the new ComponentLoader.
How do I trigger a UserControl LifeCycle when I load it dynamic with ComponentLoader?
Default.aspx
I have a question about the new ComponentLoader.
How do I trigger a UserControl LifeCycle when I load it dynamic with ComponentLoader?
Default.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Ext.Net" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<!DOCTYPE html>
<script runat="server">
[DirectMethod]
public static string LoadUserControl(string parameters)
{
return ComponentLoader.ToJson("~/WebUserControl1.ascx");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel
runat="server"
Height="200"
Width="500"
Layout="FitLayout"
Title="Load UserControl from the Page (static DirectMethod, manual loading)">
<Loader
runat="server"
AutoLoad="false"
DirectMethod="#{DirectMethods}.LoadUserControl"
Mode="Component">
<LoadMask ShowMask="true" />
</Loader>
<Buttons>
<ext:Button runat="server" Text="Load" Icon="PluginGo">
<Listeners>
<Click Handler="this.up('panel').load();this.disable();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Panel>
</body>
</html>
WebUserControl1.aspx<%@ Control Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
public class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
[DirectMethod]
public static void HelloWorld()
{
X.Msg.Alert("MyComponent", "Hello World!");
}
}
</script>
<ext:Container ID="Container1" runat="server" Layout="FitLayout" Border="false"
Padding="4">
<Items>
<ext:Panel runat="server" Layout="VBoxLayout">
<Items>
<ext:Label ID="Label1" runat="server" Text="Press the button" />
<ext:Button ID="Button1" runat="server" Width="100" Height="20" Text="Say...">
<Listeners>
<Click Handler="#{DirectMethods}.HelloWorld();" />
</Listeners>
</ext:Button>
</Items>
</ext:Panel>
</Items>
</ext:Container>
Last edited by Daniil; Apr 09, 2012 at 6:59 PM.
Reason: [CLOSED]