Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 67935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:20:16+00:00 2026-05-10T19:20:16+00:00

I have an ASP.Net 2.0 page that contains two UpdatePanels. The first panel contains

  • 0

I have an ASP.Net 2.0 page that contains two UpdatePanels. The first panel contains a TreeView. The second panel contains a label and is triggered by a selection in the tree. When I select a node the label gets updated as expected and the TreeNode that I clicked on becomes highlighted and the previously selected node is no longer highlighted. However if a node is original highlighted(selected) in the code-behind the highlight is not removed when selecting another node.

The markup

<asp:UpdatePanel ID='UpdatePanel1' runat='server' ChildrenAsTriggers='false' UpdateMode='Conditional'>    <ContentTemplate>       <asp:TreeView ID='TreeView1' runat='server' OnSelectedNodeChanged='TreeView1_SelectedNodeChanged'>          <SelectedNodeStyle BackColor='Pink' />       </asp:TreeView>    </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID='UpdatePanel2' runat='server' ChildrenAsTriggers='True'>    <ContentTemplate>       <asp:Label ID='Label1' runat='server' Text=' - '></asp:Label>    </ContentTemplate>    <Triggers>       <asp:AsyncPostBackTrigger ControlID='TreeView1' EventName='SelectedNodeChanged' />    </Triggers> </asp:UpdatePanel> 

The code behind

protected void Page_Load(object sender, EventArgs e) {    if (!IsPostBack)    {       TreeView1.Nodes.Add(new TreeNode('Test 1', 'Test One'));       TreeView1.Nodes.Add(new TreeNode('Test 2', 'Test Two'));       TreeView1.Nodes.Add(new TreeNode('Test 3', 'Test Three'));       TreeView1.Nodes.Add(new TreeNode('Test 4', 'Test Four'));       TreeView1.Nodes[0].Selected = true;    } }  protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) {    Label1.Text = TreeView1.SelectedValue; } 

The at the start the first node is selected. Why is its highlight not removed when selecting another node?

Also, I asked a different question about the same setup that I haven’t got an answer for. Any help would appreciated.

Edit I know that setting ChildrenAsTriggers='false' will work but I want to avoid rendering the tree again as it can be very large.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:20:17+00:00Added an answer on May 10, 2026 at 7:20 pm

    This may be a bit of a hack but this will clear the selection on the client and avoid updating the panel.

    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function BeginRequestHandler(sender, args)    {       var elem = args.get_postBackElement();       var selectedClassName = elem.id + '_1';        var arrAllElements = GetElementsByClassName(selectedClassName, elem);       var selectedNode = $get(elem.id + '_SelectedNode').value;        for(var i = 0; i < arrAllElements.length; i++)       {          if(arrAllElements[i].childNodes[0].id != selectedNode)             RemoveClassName(arrAllElements[i], selectedClassName );       }    } ); 

    It removes the selected style/class from all tree nodes unless its value is contained in the ‘_SelectedNode’ hidden field. GetElementsByClassName and RemoveClassName are in my own js library but are obvious enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET page that contains two div's. Both have search fields and
I have an ASP.Net page that contains a <div> with an <img> tag within.
I have a ASP.NET web page that contains many textboxes. Each textbox has a
I have a page which contains a html.RenderPartial, that renders an ASP.NET MVC partial
I have a C#/ASP.NET .aspx page that declares two controls that each represents the
I have an ASP.NET Page that contains a User control called ReportCtrl (my own
I have an ASP.NET page that contains a form and a button. In order
Novice question I guess: The Scenario: I have an asp.net page that contains 6
I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)
I have an asp.net page that calls a dll that will start a long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.