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 3212916
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:53:16+00:00 2026-05-17T14:53:16+00:00

I have a tree view control build dynamically. i want to change color of

  • 0

I have a tree view control build dynamically. i want to change color of the selected node
.one help me to write the script given below. and its work fine.

 <script type="text/javascript"  src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1.4.2");
    google.setOnLoadCallback(function() {
        //change cursor to hand when user mouseover tree nodes
        $(".TreeView1_0").mouseover(function() {
            $(this).css('cursor', 'pointer');
        });


        //unbold all nodes then bold the selected node to indicate it's selected
        $(".TreeView1_0").click(function() {
            $(".TreeView1_0").css('font-weight', 'normal');
            $(".TreeView1_0").css('color', 'black');
            $(".TreeView1_0").css('background-color', 'white');


            $(this).css('color', 'white');

            $(this).css("background-color", "blue");

        });
    });
</script>

Now i want to change the source file to the js file stored in script folder.And store selected node index and value in hidden fields.i have a source file JQuery1.4.1.js in script folder. i dont know what is the exact way of referencing to this js file. and i dont know how to retrieve selected node index and value

i changed the code to do that.the entire aspx code is shown below

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;>

<html xmlns=”http://www.w3.org/1999/xhtml&#8221;>
<head id=”Head1″ runat=”server”>
<title></title>

   <script type="text/javascript" src="../../Scripts/JQuery1.4.1.js"></script>
  <script type="text/javascript">


        //change cursor to hand when user mouseover tree nodes
        $(".TreeView1_0").mouseover(function() {
            $(this).css('cursor', 'pointer');
        });


        //unbold all nodes ,then bold the selected node to indicate it's selected ,and store  selected node index and value to two hidden fields
        $(".TreeView1_0").click(function() {
            $(".TreeView1_0").css('font-weight', 'normal');
            $(".TreeView1_0").css('color', 'black');
            $(".TreeView1_0").css('background-color', 'white');
            $(this).css('color', 'white');
            $(this).css("background-color", "blue");

          // i am not sure about the two lines of code given below
            document.getElementById('hfvalue').value = $(this).value;
            document.getElementById('hfindex').value =$(this).index;

            $(this).css('color', 'white');

            $(this).css("background-color", "blue");

        });

</script>

</head>

<body>

<form id="form1" runat="server">
<div>
    <asp:TreeView ID="TreeView1" runat="server">
    </asp:TreeView>
</div>
<p>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    <asp:HiddenField ID="hfvalue" runat="server" />
    <asp:HiddenField ID="hfindex" runat="server" />
</p>
</form>

</body>
</html>

But the code is not working . i am a newbie. Any suggestions

  • 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. Editorial Team
    Editorial Team
    2026-05-17T14:53:16+00:00Added an answer on May 17, 2026 at 2:53 pm

    I guess, first you need to make a small change in your script. Check out the following snippet to use document.ready –

    $(document).ready(function(){

       //change cursor to hand when user mouseover tree nodes
    
       $(".TreeView1_0").mouseover(function() {
    
           $(this).css('cursor', 'pointer');
    
       });
    
       //unbold all nodes ,then bold the selected node to indicate it's selected ,and store  selected node index and value to two hidden fields
    
       $(".TreeView1_0").click(function() {
    
           $(".TreeView1_0").css('font-weight', 'normal');
    
           $(".TreeView1_0").css('color', 'black');
    
           $(".TreeView1_0").css('background-color', 'white');
    
           $(this).css('color', 'white');
    
           $(this).css("background-color", "blue");
    
         // i am not sure about the two lines of code given below
    
           document.getElementById('hfvalue').value = $(this).value;
    
           document.getElementById('hfindex').value =$(this).index;
    
           $(this).css('color', 'white');
    
           $(this).css("background-color", "blue");
    
       });
    

    });

    Also, please make sure that the jquery script does get picked up properly, and the path you are using is appropriate. A simple way to verify this is to type the following into the address bar and see if the alert shows up a function

    javascript:alert($)

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

Sidebar

Related Questions

Hello All I am using infragsitics tree view control.I have one stored procedure that
I have one Tree View Control with check boxes in my Windows Forms Application.How
I have a treeview control in my web application. I build this tree view
I have a web application where I am using asp.net tree view control to
I have created a custom tree view control in .NET to display directories. What
i am using one tree view control in asp.net, in this tree view i
I have a tree view on the left side. Selecting a node displays relevant
I have a tree view control which I have to bind a dataset with
I have web page in ASP.NET. I have created Tree View control with jQuery.
In my asp.net web application, i have a tree view control with checkbox enabled.Now

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.