M
Mike Collins
I have a treeview, which is in an accordion, which is in an updatepanel. When
I click on a node in the treeview, it loads up a control as it should. When I
click on the same node again, the previously loaded control disappears and
does not get reloaded. I am not sure how this is happening. Can someone tell
me why this is happening and show me how to stop the control from being
unloaded.
HTML and event for the treeview:
<asp:UpdatePanel ID="upMain" runat="server">
<ContentTemplate>
<ajaxToolkit:Accordion ID="AccordionHome" runat="server"
ContentCssClass="accordionContent"
FadeTransitions="true" FramesPerSecond="40"
HeaderCssClass="accordionHeader"
RequireOpenedPane="false" SelectedIndex="9"
SuppressHeaderPostbacks="true" TransitionDuration="40"
Width="275px" AutoSize="None">
<Panes>
<ajaxToolkit:AccordionPane ID="apAccountSetup" runat="server"
ToolTip="Click to Expand / Collapse">
<Header>
<a class="accordionLink" href="" onclick="hide('divPH1');
hide('divPH2'); return false;">
1A Account Setup</a></Header>
<Content>
<asp:ImageButton ID="btnNoteClient" runat="server"
ImageUrl="Images/Accordion/notes.gif"
ImageAlign="Right" CausesValidation="False" CommandName="Note"
CommandArgument="Client"
ToolTip="Development Notes" OnClick="btnNoteClient_Click" />
<asp:TreeView ID="tvAccountSetup" runat="server"
SelectedNodeStyle-BackColor="Yellow"
Font-Size="10pt" Font-Bold="True"
NodeStyle-HorizontalPadding="5px"
OnSelectedNodeChanged="tvAccountSetup_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Value="Insights" Text="Insights"
ImageUrl="Images/Accordion/lightbulb.gif" />
<asp:TreeNode Value="ClientProfile" Text="Airline Profile"
ImageUrl="Images/Accordion/icon_left.gif" />
<asp:TreeNode Value="ClientBase" Text="Primary Program
Currency" ImageUrl="Images/Accordion/icon_left.gif" />
<asp:TreeNode Value="Help" Text="Help"
ImageUrl="Images/Accordion/qmark.gif" />
</Nodes>
</asp:TreeView>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
</ContentTemplate>
</asp:UpdatePanel>
protected void tvAccountSetup_SelectedNodeChanged(object sender, EventArgs e)
{
//In case the page cannot be found, with this code in a try catch, it will
not error.
try
{
PlaceHolder1.Controls.Clear();
//Return the ID of the treeview. This will correspond to the folder the
//user control is located under.
//all tree views on the default page use the same two-character prefix
naming convention.
Control c = Page.LoadControl(@"UserControls\" +
tvAccountSetup.ID.Substring(2) + @"\" + tvAccountSetup.SelectedValue +
".ascx");
PlaceHolder1.Controls.Add(c);
}
catch
{
}
}
I click on a node in the treeview, it loads up a control as it should. When I
click on the same node again, the previously loaded control disappears and
does not get reloaded. I am not sure how this is happening. Can someone tell
me why this is happening and show me how to stop the control from being
unloaded.
HTML and event for the treeview:
<asp:UpdatePanel ID="upMain" runat="server">
<ContentTemplate>
<ajaxToolkit:Accordion ID="AccordionHome" runat="server"
ContentCssClass="accordionContent"
FadeTransitions="true" FramesPerSecond="40"
HeaderCssClass="accordionHeader"
RequireOpenedPane="false" SelectedIndex="9"
SuppressHeaderPostbacks="true" TransitionDuration="40"
Width="275px" AutoSize="None">
<Panes>
<ajaxToolkit:AccordionPane ID="apAccountSetup" runat="server"
ToolTip="Click to Expand / Collapse">
<Header>
<a class="accordionLink" href="" onclick="hide('divPH1');
hide('divPH2'); return false;">
1A Account Setup</a></Header>
<Content>
<asp:ImageButton ID="btnNoteClient" runat="server"
ImageUrl="Images/Accordion/notes.gif"
ImageAlign="Right" CausesValidation="False" CommandName="Note"
CommandArgument="Client"
ToolTip="Development Notes" OnClick="btnNoteClient_Click" />
<asp:TreeView ID="tvAccountSetup" runat="server"
SelectedNodeStyle-BackColor="Yellow"
Font-Size="10pt" Font-Bold="True"
NodeStyle-HorizontalPadding="5px"
OnSelectedNodeChanged="tvAccountSetup_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Value="Insights" Text="Insights"
ImageUrl="Images/Accordion/lightbulb.gif" />
<asp:TreeNode Value="ClientProfile" Text="Airline Profile"
ImageUrl="Images/Accordion/icon_left.gif" />
<asp:TreeNode Value="ClientBase" Text="Primary Program
Currency" ImageUrl="Images/Accordion/icon_left.gif" />
<asp:TreeNode Value="Help" Text="Help"
ImageUrl="Images/Accordion/qmark.gif" />
</Nodes>
</asp:TreeView>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
</ContentTemplate>
</asp:UpdatePanel>
protected void tvAccountSetup_SelectedNodeChanged(object sender, EventArgs e)
{
//In case the page cannot be found, with this code in a try catch, it will
not error.
try
{
PlaceHolder1.Controls.Clear();
//Return the ID of the treeview. This will correspond to the folder the
//user control is located under.
//all tree views on the default page use the same two-character prefix
naming convention.
Control c = Page.LoadControl(@"UserControls\" +
tvAccountSetup.ID.Substring(2) + @"\" + tvAccountSetup.SelectedValue +
".ascx");
PlaceHolder1.Controls.Add(c);
}
catch
{
}
}