Dec 15, 2009, 7:58 AM
Load usercontrol by AjaxEvents
Hi,
can I load my user controls by AjaxEvents? Please look a t my code below.
It works in the page_load but it does not work in the AjaxMethod.
LeftMenu.ascx
<ext:MenuPanel ID="MenuPanel1" runat="server" Title="Modules" Icon="ArrowSwitch">
<Menu>
<Items>
<ext:MenuItem ID="NewModule" runat="server" Text="Add new Module" Icon="ArrowRight" />
<ext:MenuItem ID="ModuleList" runat="server" Text="Module List" Icon="ArrowRight" />
<ext:MenuItem ID="ModulePlacement" runat="server" Text="Change module place" Icon="ArrowRight" />
</Items>
<AjaxEvents>
<ItemClick OnEvent="MenuItemClickAjax" >
<EventMask ShowMask="true" />
<ExtraParams>
<ext:Parameter Name="title" Value="e.text" />
</ExtraParams>
</ItemClick>
</AjaxEvents>
</Menu>
</ext:MenuPanel>
[AjaxMethod]
protected void MenuItemClickAjax(object sender, AjaxEventArgs e)
{
Control uc = LoadControl("~/UserControls/ModuleList.ascx");
MasterPage mainPage = this.Parent.Page.Master;
ContentPlaceHolder ph = mainPage.FindControl("cphMiddle1") as ContentPlaceHolder;
ph.Controls.Add(uc);
}
Do you have any idea?
All suggestions are welcome.
Thank you in advance.