CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 8/7/2007 2:15:54 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 227 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
Jayran
Asp.Net User
asp.net 2.0 Treeview control - selectedNodestyle - using javascript8/7/2007 2:15:54 PM

0

Good Morning All,
 
Need help in setting the backcolor of a selected node in asp.net 2.0' s treeview control, without postback.

This is what I did:
 1.Populated the treeview control using a collection(of nodes).
 2.For each TreeNode created , set the NavigateUrl property,
                    child.NavigateUrl = "javascript:SelectNode(this," + node.NodeId +")";
 3.Javascript:
  var prevNode= null;
  function SelectNode(currentNode, nodeId)
  {
    
      if(prevNode!=null)
          prevNode.className='';
      currentNode.className='selected';
         
      prevNode= currentNode;
  }
 

Question / Problem:
 1.alert(currentNode) gives object, but color dont change.
 2.alert(currentNode.id) gives undefined even though the viewsource shows something like this:

  <table cellpadding="0" cellspacing="0" style="border-width:0;">
   <tr>
    <td><div style="width:10px;height:1px"><img src="/WebResource.axd?d=P4RU-hSsdH2kOfIwJeYucpQuKE03aRBqIWkkbK1ZiYE1&amp;t=633217587889533860" alt="" /></div></td><td><img src="/WebResource.axd?d=P4RU-hSsdH2kOfIwJeYuci_CkJj3oPaIAvyG7pay0L01&amp;t=633217587889533860" alt="" /></td><td style="white-space:nowrap;padding:0px 5px 0px 5px;"><a href="javascript:SelectNode(this,641);" id="treeviewDomianst7" style="text-decoration:none;">xxxxxxxx</a></td>
   </tr>
  </table>


What's wrong?? Why not alert(currentNode.id) return the correct id (treeviewDomianst7) ??
Appreciate any solution (without postback)

thanks.

Jayran
Asp.Net User
Re: asp.net 2.0 Treeview control - selectedNodestyle - using javascript8/9/2007 4:43:37 PM

0

Hello guys , seems no one is using the tree control as I am using or everyone is too busy.

However , I am able to do what I wanted.

got the idea from this link :  http://www.codeproject.com/useritems/focusBGColor.asp

This is what I did in javascript:

 Attached function to onclick event of the treenode ( the anchor)

window.onload = setTreeFunction;

function setTreeFunction()

{

 

var divTree = document.getElementById('divTree');var anc = divTree.getElementsByTagName('a');

 

for(var i = 0; i < anc.length; i++)

{

if(anc[i].id.indexOf('treeviewDomians') != -1)

{

anc[i].attachEvent(
"onclick",changeAnchorStyle);

 

}

}

}

function changeAnchorStyle(e)

{

var src = e.srcElement || e.target;

 

if(prevAnchor !=null) prevAnchor.className='';if(src !=null)

{

src.className=
'selected';

prevAnchor= src;

}

 

 

}

Let me know if there is a better solution.

Thanks

 

 

Jayran
Asp.Net User
Re: asp.net 2.0 Treeview control - selectedNodestyle - using javascript8/9/2007 4:43:48 PM

0

Please let me know if there is a better solution

Johnson2007
Asp.Net User
Re: asp.net 2.0 Treeview control - selectedNodestyle - using javascript8/10/2007 8:27:06 AM

0

I think there is not any solution is the best for everybody, they depend on your programming habits and skill or programming patterns. Your solution is very good I think. Another answer you can apperceive from http://www.codeproject.com/aspnet/ClientSideTreeView.asp.

May it helps... Thanks.


Johnson
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Core Internet application development with ASP.NET 2.0 Authors: Randy Connolly, Pages: 1049, Published: 2007
Beginning ASP.NET 2.0 with C# Authors: Chris Hart, John Kauffman, David Sussman, Chris Ullman, Pages: 735, Published: 2006
Beginning ASP.NET 2.0 Authors: Chris Hart, John Kauffman, Chris Ullman, David Sussman, Pages: 759, Published: 2005
ASP.NET AJAX programmer's reference with ASP.NET 2.0 or ASP.NET 3.5 Authors: Shahram Khosravi, Pages: 1522, Published: 2007
Pro ASP.NET 2.0 in VB 2005 Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006

Web:
.Net 2..0 Tree view control Selected node style changed using ... Please give me an sample code Net 2..0 Tree view control Selected node style changed using javascript. Thanks ...
ASP.Net Newbie: Question on Treeview Control Styles : treeview ... Im simply trying to manipulate the styles for the tree view control. ... That is , the Selected Style (SelectedNodeStyle) and the Hover Style (HoverNodeStyle). ... "; ...
ASP.NET Treeview selectedNodeStyle Talk about ASP.NET Treeview selectedNodeStyle. ... issue of the TreeView control , the dev team has recorded this for ... Value="New Node12" NavUrl="http://www. asp.net/?id=2"> ... string script = @"






using enterprise library data access block

html source code of outputted aspx page

sample vb code for task scheduler

question on freeing objects

skmmenu against sql server db ?

web.mail

3-tiere architecture using asp.net

whidbey and standards

the difference between creating an instance of an object

please forgive me, but what is asp?

is it possible to replace upload image with resized one?

vb.net null date

how to create a site for multiple language

http 1.0 500 server error

how to invisable underline in hyperlink?

databases and directories....

response.redirect target

hosting vwd 2005 application on go.daddy

allowpaging [error:object reference not set to an instance of an object.]

executing my function in c#

iterate through a data table

how to assign value to enum variables at runtime in c#

inserting a javascript effect on a c# .aspx page

including local variable state in an exception throw

begininvoke/endinvoke with medium trust

how upload multiple image to database

fix error

security check question

slleep (),abort()

login authentication

   
  Privacy | Contact Us
All Times Are GMT