Hi,
I am new to implementing Asynchronous javascript in asp.net (or any framework) and have come across a problem.
In a user control I have an accordion with a nested updatepanel, the trigger is a link button in the header. I have read several posts that suggest I need to add the ControlID in the codebehind, so I have and I don't get any errors, but also there's nothing loading into the updatepanel.
Here's the code;
Codebehind:
apsx page:
Any help would be appreciated.
I am new to implementing Asynchronous javascript in asp.net (or any framework) and have come across a problem.
In a user control I have an accordion with a nested updatepanel, the trigger is a link button in the header. I have read several posts that suggest I need to add the ControlID in the codebehind, so I have and I don't get any errors, but also there's nothing loading into the updatepanel.
Here's the code;
Codebehind:
Code:
protected void Page_Init(object sender, EventArgs e) { LinkButton UserLink = Accordion1.FindControl("UserLink") as LinkButton; ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(UserLink); //Creates a new async trigger AsyncPostBackTrigger trigger = new AsyncPostBackTrigger(); //Sets the control that will trigger a post-back on the UpdatePanel trigger.ControlID = "UserLink"; //Sets the event name of the control trigger.EventName = "Click"; //Adds the trigger to the UpdatePanels' triggers collection UpdatePanelUser.Triggers.Add(trigger); } protected void Page_Load(object sender, EventArgs e) { } protected void UserLink_Click(object sender, EventArgs e) { String userPanelPath = "~/CMS/_admin/_components/CMS_controls/admin_controls/UserPanel.ascx"; Control userPanel = Page.LoadControl(userPanelPath); PanelUser.Controls.Add(userPanel); }
Code:
<ajaxToolkit:Accordion ID="Accordion1" runat="server" HeaderSelectedCssClass="AdminPanelHeaderSelected" RequireOpenedPane="false" SuppressHeaderPostbacks="true" SelectedIndex="0" HeaderCssClass="AdminPanelHeader" ContentCssClass="AdminPanelContent" FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" AutoSize="none"> <Panes> <ajaxToolkit:AccordionPane runat="server" ID="Home" > <Header> <a href="" onclick="return false;">Home</a> </Header> <Content> </Content> </ajaxToolkit:AccordionPane> <ajaxToolkit:AccordionPane runat="server" ID="UserPanel"> <Header> <asp:LinkButton ID="UserLink" runat="server">User panel</asp:LinkButton> </Header> <Content> <asp:UpdatePanel ID="UpdatePanelUser" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="PanelUser" runat="server"> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </Content> </ajaxToolkit:AccordionPane> <ajaxToolkit:AccordionPane runat="server" ID="STATS"> <Header> <a href="" onclick="return false;">Statistics</a> </Header> <Content> </Content> </ajaxToolkit:AccordionPane> <ajaxToolkit:AccordionPane runat="server" ID="GroupEmails"> <Header> <a href="" onclick="return false;">Group Email</a> </Header> <Content> </Content> </ajaxToolkit:AccordionPane> <ajaxToolkit:AccordionPane runat="server" ID="Errors"> <Header> <a href="" onclick="return false;">Error reporting</a> </Header> <Content> </Content> </ajaxToolkit:AccordionPane> </Panes> </ajaxToolkit:Accordion>