treeview - Javascript - Set source file and assigning value to a control -


i have tree view control build dynamically. want change color of selected node .one me write script given below. , 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 hand when user mouseover tree nodes         $(".treeview1_0").mouseover(function() {             $(this).css('cursor', 'pointer');         });           //unbold nodes bold selected node 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 want change source file js file stored in script folder.and store selected node index , value in hidden fields.i have source file jquery1.4.1.js in script folder. dont know exact way of referencing js file. , dont know how retrieve selected node index , value

i changed code that.the entire aspx code 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">

<html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1" runat="server"> <title></title>

   <script type="text/javascript" src="../../scripts/jquery1.4.1.js"></script>   <script type="text/javascript">           //change cursor hand when user mouseover tree nodes         $(".treeview1_0").mouseover(function() {             $(this).css('cursor', 'pointer');         });           //unbold nodes ,then bold selected node indicate it's selected ,and store  selected node index , value 2 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");            // not sure 2 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 code not working . newbie. suggestions

i guess, first need make small change in script. check out following snippet use document.ready -

$(document).ready(function(){

   //change cursor hand when user mouseover tree nodes     $(".treeview1_0").mouseover(function() {         $(this).css('cursor', 'pointer');     });     //unbold nodes ,then bold selected node indicate it's selected ,and store  selected node index , value 2 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");       // not sure 2 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 jquery script picked properly, , path using appropriate. simple way verify type following address bar , see if alert shows function

javascript:alert($)


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -