PDA

View Full Version : [CLOSED] Loadind UserControls with DirectMethod dynamicly



odyssey
Feb 13, 2013, 6:56 PM
http://examples2.ext.net/#/Loaders/Component/Direct_Method/
In Examples above NONE was presented as scenario where usercontrol had DirectMethod.Is it possible to call a directmethod from usercontrol when its loaded at run time ?

geoffrey.mcgill
Feb 13, 2013, 8:14 PM
Can you kick things off by providing a simplified sample demonstrating as much of the scenario as possible?

odyssey
Feb 14, 2013, 7:28 AM
Can you kick things off by providing a simplified sample demonstrating as much of the scenario as possible?
Well in examples http://examples2.ext.net/#/Loaders/Component/Direct_Method/
shows a way how to bring UserControls in main Form but it is not raising any events on UserControl it just string representation of usercontrol
for ex.


//user control
<ext:Container runat="server" Layout="BorderLayout" Border="false" Padding="4">
<Items>
<ext:Panel runat="server" Region="West" Title="West" Split="true" Width="150" Collapsible="true"
Icon="ApplicationSideExpand" />
<ext:Panel runat="server" Region="Center" Title="Center" />
<ext:Panel runat="server" Region="East" Title="East" Split="true" Width="150" Collapsible="true"
Icon="ApplicationSideContract">
<Items>
<ext:Button runat="server" Text="Get Server Time">
<Listeners>
<Click Handler="App.direct.getTime">
</Click>
</Listeners>
</ext:Button>
</Items>
</ext:Panel>
</Items>
</ext:Container>
// main page calling
[DirectMethod]
public static string UserControl()
{
return ComponentLoader.ToConfig("~/UserCtr/Items.ascx");

}

Daniil
Feb 14, 2013, 9:55 AM
Hello,

ComponentLoader doesn't maintain a loaded user control during other requests.

But to execute a user control's DirectMethod handler, a user control instance must be on a server. Otherwise, no a user control => no a DirectMethod handler.

Personally, I would refer a generic handler (ASHX) or a web service (ASMX). This call won't require a user control instance.