Hi Morris,
FYI, the email is being sent by my colleague Jer Mehta.
Thanks for your update. From the description my understanding is like below:
" The page is products-cm.aspx
" On the page there's a TreeView like below:
<div>
<h6><a
href="products-cm.aspx?ViewIndex=1">Features</a></h6>
<asp:TreeView id="TreeView1" runat="server" NodeIndent="0"
NodeWrap="True" Width="217px">
<Nodes>
<asp:treenode Expanded="True" NavigateUrl="products-cm.aspx?ViewIndex=1"
SelectAction="SelectExpand" Text="Basic" Value="Basic">
<asp:treenode Text="Messaging" Value="Messaging"
NavigateUrl="products-cm.aspx?ViewIndex=5" SelectAction="SelectExpand">
</asp:treenode>
<asp:treenode Text="Call Routing" Value="CallRouting"
NavigateUrl="products-cm.aspx?ViewIndex=6">
</asp:treenode>
<asp:treenode Text="IVR/Audiotex" Value="IVRAudiotex"
NavigateUrl="products-cm.aspx?ViewIndex=7">
</asp:treenode>
</asp:treenode>
<asp:treenode Expanded="True" NavigateUrl="products-cm.aspx?ViewIndex=1"
SelectAction="SelectExpand" Text="Advanced" Value="Advanced">
<asp:treenode Text="CALLBasic Scripting" Value="CALLBasic"
NavigateUrl="products-cm.aspx?ViewIndex=10">
</asp:treenode>
<asp:treenode Text="Speech Recognition (ASR)" Value="ASR"
NavigateUrl="products-cm.aspx?ViewIndex=11">
</asp:treenode>
<asp:treenode Text="Text-to-Speech (TTS)" Value="TTS"
NavigateUrl="products-cm.aspx?ViewIndex=12">
</asp:treenode>
</asp:treenode>
</Nodes>
<NodeStyle />
<LeafNodeStyle Font-Size="10px" ForeColor="#333333"
ImageUrl="customimages/Arrow-Blck.gif" />
</asp:TreeView>
</div>
The expected behavior is:
" Initially all nodes of the TreeView are collapsed.
" After clicking any "+" icon to expand node and then click the child node
to navigate to the same page (with querystring ViewIndex), the expanded
node must maintain it's state. Namely if it's expanded before navigation it
must still be expanded after navigation.
Is my understanding right? If it is, I think you can use following code:
<div>
<h6><a href="products-cm.aspx?ViewIndex=1">Features</a></h6>
<asp:TreeView id="TreeView1" runat="server" NodeIndent="0"
NodeWrap="True"
Width="217px" >
<Nodes>
<asp:treenode Expanded="True"
NavigateUrl="javascript:__doPostBack('ViewIndex','1')"
SelectAction="SelectExpand" Text="Basic" Value="Basic">
<asp:treenode Text="Messaging" Value="Messaging"
NavigateUrl="javascript:__doPostBack('ViewIndex','5')"
SelectAction="SelectExpand">
</asp:treenode>
<asp:treenode Text="Call Routing" Value="CallRouting"
NavigateUrl="javascript:__doPostBack('ViewIndex','6')">
</asp:treenode>
<asp:treenode Text="IVR/Audiotex" Value="IVRAudiotex"
NavigateUrl="javascript:__doPostBack('ViewIndex','7')">
</asp:treenode>
</asp:treenode>
<asp:treenode Expanded="True"
NavigateUrl="javascript:__doPostBack('ViewIndex','1')"
SelectAction="SelectExpand" Text="Advanced" Value="Advanced">
<asp:treenode Text="CALLBasic Scripting" Value="CALLBasic"
NavigateUrl="javascript:__doPostBack('ViewIndex','10')">
</asp:treenode>
<asp:treenode Text="Speech Recognition (ASR)" Value="ASR"
NavigateUrl="javascript:__doPostBack('ViewIndex','11')">
</asp:treenode>
<asp:treenode Text="Text-to-Speech (TTS)" Value="TTS"
NavigateUrl="javascript:__doPostBack('ViewIndex','12')">
</asp:treenode>
</asp:treenode>
</Nodes>
<NodeStyle />
<LeafNodeStyle Font-Size="10px" ForeColor="#333333"
ImageUrl="customimages/Arrow-Blck.gif" />
</asp:TreeView>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
TreeView1.CollapseAll();
}
if (Request.Form["__EVENTTARGET"] == "ViewIndex") {
if (!String.IsNullOrEmpty(Request.Form["__EVENTARGUMENT"]))
{
//test
Response.Write(Request.Form["__EVENTARGUMENT"]);
}
}
}
Your original code in aspx uses URL directly. This will cause a get request
sent to server after the child node is clicked. In this case it's difficult
to maintain the state of the control. If you have to use get request you
probably can store the state in session, which is not a good practise to
store state of control because it consumes server side memory and may
expire.
In my above code a post request will be sent to server after you clicking
the child node. In this case we can benefite from internal mechanism of
TreeView to maintain the control state during postbacks. As a result of
this routine we have to use Request.Form["__EVENTTARGET"] to figure out the
selected "ViewIndex", as shown in my code.
Regards,
Allen Chen
Microsoft Online Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.