|
Rank: Member Groups: Member
Joined: 8/16/2009 Posts: 13
|
Caould some one tell me how to prevent the Treeview Control from doing a full page postback when a treeview node is clicked?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The TreeView's RaisesServerEvent controls whether the TreeView causes a post back.
Thanks
|
|
Rank: Member Groups: Member
Joined: 8/16/2009 Posts: 13
|
Maybe I am asking the wrong question. I have the 'RaisesServerEvent' set to 'False' (the original value was NULL), however when I expand a node and click a child node a couple things always happen:
1) The Master Page does a Post back 2) All the nodes on the TRee View gets closed
How can I keep the TreeView expanded and also keep the clicked node highlighted?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The TreeView should keep expanded status automatically regardless whether you post back or not if you are in the same page. If you are in a different page, it will not save status unless you have SaveStateCrossPages set to true.
The TreeView will automatically post back if you have RaisesServerEvent set to true on the TreeView or on the TreeNode (each TreeNode also has RaisesServerEvent). Otherwise it should not automatically post back. If it still posts back, then it most likely is in your event handling code.
If the problem continues, we will need you to isolate the problem into a test page. We will be happy to look into that as soon as we have it.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/16/2009 Posts: 13
|
Thanks for your response. I have created a brand new, very project with one master page and 2 content pages. The Master page as a tree view on it and it is doing the same thing. How can I share the project with you?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Please see your private message as to where to send.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/16/2009 Posts: 13
|
Thanks, I have sent it..
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, We have looked into the code. The TreeView in your sample is not doing a full post back. It simply navigates the page from one page to another (in your case switches between Hello1.aspx and Hello2.aspx) because the nodes' NavigateUrl are set. If you wish to save expanded and selected when you switch pages, you need to modify your code as: 1. Remove all the TreeNode in your .aspx file. Those nodes are not necessary because your TreeView is populated from your XmlDataSource; 2. Add the following code into your MasterPage:
Code: C#
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//This is necessary to make sure TreeView1 is populated
//before it tries to reload state information
TreeView1.DataBind();
}
Hope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/16/2009 Posts: 13
|
Awsome!!! It works as I hoped. Thanks for such an extremely fast investigation and response.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Glad that it works for you! Please feel free to let us know if you have any more questions.
Thanks!
|
|