Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   TreeView (http://www.velocityreviews.com/forums/t781045-treeview.html)

Morris Neuman 06-24-2009 08:05 PM

TreeView
 

Hi,

I have a page with a TreeView. The TreeView contains 2 nodes, each node
containing several leaf nodes.

By setting the parent node Expansion to false, the treeview always shows
un-expanded. If I set expansion to true that it always shows expanded.

Below is my treeview structure. I want the treeview not to show expanded
until the user clicks to expand, then I want it to remain expanded until they
minimize.

Appreciate your help.
--
Thanks
Morris

Allen Chen [MSFT] 06-25-2009 05:59 AM

RE: TreeView
 

Hi Morris,

>Below is my treeview structure. I want the treeview not to show expanded
>until the user clicks to expand, then I want it to remain expanded until

they
>minimize.


I cannot see your TreeView. Is it something like this?

<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Text="Root" Value="Root">
<asp:TreeNode Text="Node1" Value="Node1">
<asp:TreeNode Text="Leaf Node1" Value="Leaf
Node1"></asp:TreeNode>
<asp:TreeNode Text="Leaf Node2" Value="Leaf
Node2"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="Node2" Value="Node2">
<asp:TreeNode Text="Leaf Node1" Value="Leaf
Node1"></asp:TreeNode>
<asp:TreeNode Text="Leaf Node2" Value="Leaf
Node2"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>

If so could you clarify your requirement? I have several different
understandings according to your above description. To avoid
misunderstanding you can send me some screenshots and clarify it in detail.
You can send screenshots to allenc@microsoft.com. Please update here after
sending in case I missed that email.

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:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




Morris Neuman 06-25-2009 10:44 PM

RE: TreeView
 

Thanks for the reply.

I have emailed details to your email as requested.
--
Thanks
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> >Below is my treeview structure. I want the treeview not to show expanded
> >until the user clicks to expand, then I want it to remain expanded until

> they
> >minimize.

>
> I cannot see your TreeView. Is it something like this?
>
> <asp:TreeView ID="TreeView1" runat="server">
> <Nodes>
> <asp:TreeNode Text="Root" Value="Root">
> <asp:TreeNode Text="Node1" Value="Node1">
> <asp:TreeNode Text="Leaf Node1" Value="Leaf
> Node1"></asp:TreeNode>
> <asp:TreeNode Text="Leaf Node2" Value="Leaf
> Node2"></asp:TreeNode>
> </asp:TreeNode>
> <asp:TreeNode Text="Node2" Value="Node2">
> <asp:TreeNode Text="Leaf Node1" Value="Leaf
> Node1"></asp:TreeNode>
> <asp:TreeNode Text="Leaf Node2" Value="Leaf
> Node2"></asp:TreeNode>
> </asp:TreeNode>
> </asp:TreeNode>
> </Nodes>
> </asp:TreeView>
>
> If so could you clarify your requirement? I have several different
> understandings according to your above description. To avoid
> misunderstanding you can send me some screenshots and clarify it in detail.
> You can send screenshots to allenc@microsoft.com. Please update here after
> sending in case I missed that email.
>
> 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>


Morris Neuman 06-25-2009 10:50 PM

RE: TreeView
 

FYI, the email is being sent by my colleague Jer Mehta.
--
Thanks
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> >Below is my treeview structure. I want the treeview not to show expanded
> >until the user clicks to expand, then I want it to remain expanded until

> they
> >minimize.

>
> I cannot see your TreeView. Is it something like this?
>
> <asp:TreeView ID="TreeView1" runat="server">
> <Nodes>
> <asp:TreeNode Text="Root" Value="Root">
> <asp:TreeNode Text="Node1" Value="Node1">
> <asp:TreeNode Text="Leaf Node1" Value="Leaf
> Node1"></asp:TreeNode>
> <asp:TreeNode Text="Leaf Node2" Value="Leaf
> Node2"></asp:TreeNode>
> </asp:TreeNode>
> <asp:TreeNode Text="Node2" Value="Node2">
> <asp:TreeNode Text="Leaf Node1" Value="Leaf
> Node1"></asp:TreeNode>
> <asp:TreeNode Text="Leaf Node2" Value="Leaf
> Node2"></asp:TreeNode>
> </asp:TreeNode>
> </asp:TreeNode>
> </Nodes>
> </asp:TreeView>
>
> If so could you clarify your requirement? I have several different
> understandings according to your above description. To avoid
> misunderstanding you can send me some screenshots and clarify it in detail.
> You can send screenshots to allenc@microsoft.com. Please update here after
> sending in case I missed that email.
>
> 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>


Allen Chen [MSFT] 06-26-2009 02:02 AM

RE: TreeView
 

Hi Morris,

>FYI, the email is being sent by my colleague Jer Mehta.
>--
>Thanks
>Morris


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:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




Morris Neuman 06-26-2009 11:51 AM

RE: TreeView
 

Allen,

The code worked but did not work. The treeview behaved as I wanted, however
the navigate urls did not take me to the correct page when clicked. I have
emailed you the details with an attachment showing the screen behaviour.

--
Thanks for your help as always.
Morris


"Allen Chen [MSFT]" wrote:

> Hi Morris,
>
> >FYI, the email is being sent by my colleague Jer Mehta.
> >--
> >Thanks
> >Morris

>
> 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>



All times are GMT. The time now is 01:25 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57