• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1715
  • Last Modified:

TreeView & AutoPostBack ?

I'm using the 2.0 version of the <asp:treeview /> in a page of mine.  I want the user to just select a node and hit another button outside of the treeview.  However when they select the node, the entire page posts back.  I don't want this to occur.  Is there any way to configure the TreeView to not postback when they select a node, but still be able to determine what they selected when they click this other button?

I don't see any option to control this.
0
raterus
Asked:
raterus
  • 3
1 Solution
 
DreamMasterCommented:
It used to be that <asp:treeview AutoPostBack=false /> would work, but as it seems that doesn't work anymore.

I don't think there is an option to selecting a node without a postback now. Selecting a node in the tree will cause a postback immediately.

However, there is almost always a workaround and that seems to be the case here as well...it's not pretty, but it seems to be workable.. ;)

<asp:TreeView ID="TreeView1" runat="server" Target="_self">
  <Nodes>
    <asp:TreeNode Text="One" NavigateUrl="javascript:void(0)" />
    <asp:TreeNode Text="Two" NavigateUrl="javascript:void(0)" />
  </Nodes>
  <SelectedNodeStyle Font-Bold="True" />
</asp:TreeView>

Why does it do this?  It works this way because if the Target of the NavigateUrl is not the current page (e.g. Target=_blank or Target=SomeFrame), then the page isn’t going to change.  Therefore, it needs to mark the current item as selected.

I hope this helps,

Regards,
Max.
0
 
DreamMasterCommented:
Are you still there raterus?

Regards,
Max.
0
 
raterusAuthor Commented:
Yeah, swamped with work, as usual.

I'm sure this solution will work as desired, since I can understand what you're doing, I never got around to testing it.  The asp:treeview was doing some very weird things that I looked at fixing for about a half-day, and eventually opted to trash using the control altogether, in favor of another control...with it's own quirks.

Thank you though for your help!
--Michael
0
 
DreamMasterCommented:
You are welcome :)

Regards,
Max.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now