Welcome Guest Search | Active Topics | Sign In | Register

Prevent Treeview Page Postback Options
Gordsh
Posted: Sunday, March 6, 2011 8:34:12 PM
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?
eo_support
Posted: Monday, March 7, 2011 8:49:21 AM
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
Gordsh
Posted: Monday, March 7, 2011 4:28:30 PM
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
eo_support
Posted: Monday, March 7, 2011 5:14:32 PM
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!
Gordsh
Posted: Monday, March 7, 2011 8:29:30 PM
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?
eo_support
Posted: Tuesday, March 8, 2011 9:03:25 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please see your private message as to where to send.

Thanks!
Gordsh
Posted: Tuesday, March 8, 2011 9:41:28 AM
Rank: Member
Groups: Member

Joined: 8/16/2009
Posts: 13
Thanks, I have sent it..
eo_support
Posted: Tuesday, March 8, 2011 10:43:56 AM
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!
Gordsh
Posted: Tuesday, March 8, 2011 11:07:06 AM
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.
eo_support
Posted: Tuesday, March 8, 2011 1:21:40 PM
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.