PDA

View Full Version : Delay User Control from loading



cwolcott
May 18, 2012, 5:34 PM
I found the recent thread and tried to use the suggestion to delay my user controls from rendering until the tab is selected:

Delay User Control (http://forums.ext.net/showthread.php?18270-Unable-to-use-User-Control-inside-Portlet-control-This-type-of-page-is-not-served)

I have added the listener and direct method, but I get an error "Cannot call method LoadTabRoles of undefined" when I select the tab. My aspx page uses a master page and has a content place holder for the head and body. Where should I place the <script runat="server"> [DirectMethod] section.



<script runat="server">
[DirectMethod]
public static void LoadUserControl(string containerId)
{
X.Js.AddScript(UserControlRenderer.ToScript(new UserControlRendrerConfig
{
UserControlPath = "~/Section-User/TabRoles.ascx",
Mode = RenderMode.AddTo,
SingleControl = true,
Element = containerId
}));
} </script>


UserRole.aspx


<%@ Page ... MasterPageFile="~/WAM.Master" ... %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<asp:Content ContentPlaceHolderId="HeadContent" runat="server">
<ext:XScript runat="server"
<script type="text\javascript">
... Javascript routines
</script>
</ext:XScript>
</asp:Content>

<asp:Content ContentPlaceHolderId="CenterContent" runat="server">
<script type="text\javascript">
... Javascript routines
</script>

<ext:TapPanel runat="server" Region="Center">
<ext:Panel runat="server" Title="Roles" Icon="Group" Layout="FitLayout">
<Listeners>
<AfterRender Handler="{DirectMethods}.LoadTabRoles(this.id);" />
</Listeners>
</ext:Panel>
</ext:TabPanel>
</asp:Content>

Daniil
May 21, 2012, 1:54 PM
Hi,

Posting the questions on non Premium forums causes a possibility your questions to be not answered or answered with a big delay. I've just discovered your question.

Please see the example how to refer a DirectMethod from a master page.
http://examples2.ext.net/#/Events/DirectMethods/ID_Mode/