PDA

View Full Version : [CLOSED] reference of a control loaded by component loader



mirwais
Dec 27, 2012, 4:13 PM
Hi

I am using a component loader which loads a user control throough a webservice. I need to somehow get a reference of this user control to further process things, is this possible if not is this a better way to do it: http://examples2.ext.net/#/XRender/UserControl/UpdateContent/

Here is an example of Component loader I am using it is similer to http://examples2.ext.net/#/Loaders/Component/JSON_WebService/


<%@ Page Language="C#" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void Panel1_Activated(object sender, DirectEventArgs args)
{

//how to get a reference to the user control that the loader in Panel1 loads? is it possible?
//var c = Panel1.ContentControls;
//Panel1.FindControl()
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Loader - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<h1>Component Loader (JSON WebService)</h1>

<ext:ResourceManager runat="server" />

<ext:Panel
ID="Panel1"
runat="server"
Height="200"
Width="500"
Layout="FitLayout"
Title="Load user control from JSON WebService (manual loading)">
<Loader
runat="server"
AutoLoad="false"
Url="ComponentService.asmx/UserControl"
Mode="Component">
<AjaxOptions Json="true" />
<LoadMask ShowMask="true" />
</Loader>
<Buttons>
<ext:Button runat="server" Text="Load" Icon="PluginGo">
<Listeners>
<Click Handler="this.up('panel').load();this.disable(); #{Panel1}.enable();" />
</Listeners>
</ext:Button>
</Buttons>

<DirectEvents>
<Enable OnEvent="Panel1_Activated"></Enable>
</DirectEvents>
</ext:Panel>
</body>
</html>

Baidaly
Dec 28, 2012, 12:40 AM
Hello!

There is only one way to get UserControl is to load it again as done in this example http://examples2.ext.net/#/XRender/UserControl/UpdateContent/ .

However, if you'll provide more information about how do you want to use it we can help you.

mirwais
Dec 28, 2012, 7:31 AM
However, if you'll provide more information about how do you want to use it we can help you.

well in this method I want to get a reference to the Items.asmx user control loaded by the webservice from this path "~/Examples/Loaders/_Shared/Items.ascx", like Panel1.ContentControls[0] would be my first guess but it is empty.


<script runat="server">
protected void Panel1_Activated(object sender, DirectEventArgs args)
{

//how to get a reference to the user control that the loader in Panel1 loads? is it possible?
//var c = Panel1.ContentControls;
//Panel1.FindControl()
}
</script>

I'd like to implement it with this component loader as it is an elegant way in my case, where I have many user controls which should be loaded in a panel each time user selects it. But if this is not possible I can see to do it as in Xrender example.
Thanks

Daniil
Dec 28, 2012, 10:32 AM
Hi @mirwais,

There is no way to access a user control created in a WebService.

A user control created in a WebService is "serialized" to respective JavaScript code and sent to a client (browser). The user control instance is not saved anywhere.

Could you clarify why do you need to access that user control and its controls in page's code behind?

mirwais
Dec 28, 2012, 1:05 PM
Hi @mirwais,

There is no way to access a user control created in a WebService.

A user control created in a WebService is "serialized" to respective JavaScript code and sent to a client (browser). The user control instance is not saved anywhere.

Could you clarify why do you need to access that user control and its controls in page's code behind?

Thanks for the clarification, you can close this thread. I wanted to use the control in a DirectEvent but I liked to use the component loader as this was a cleaner way to do it especially when you have more than one user control and don't want to load them automatically but based on user'w request. Now I am using a Container with a cardlayout having both user controls and I set the activeitem each time user selects a control to see. In this case ofcourse I don't have problems with getting the reference to the user control. Anyways this thread helped me at least know better the component loader and the way the web service generates the user control, thank you guys.