473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

working with TreeView, jscript/client side

Sorry folks but I will be reposting this question from 6/5 until someone
gives me an answer - the question is very easy and so ought the answer to
be. I really need the answer!

-------
I'm sorry for reposting but I've already googled for hours and I see others
have asked about this here without getting replies, this is starting to look
like some Bermuda phenomenon nobody wants to answer to! I really need to
accomplish the task below...

---
Is there any documentation out there to find out if and then how I can work
with TreeView on client side through jscript? For example I want to change
title of nodes and remove without doing postback. MS doesn't seem to have
any official documentation on this.

And please notice I'm not refering to IE TreeView control but asp.net 2.0's
TreeView!

Jun 8 '06 #1
1 2400
I may be able to help you out with this.

The biggest problem with the TreeNode is that you cannot retrieve the ID for
the node on the client side. The ID for the anchor tag that represents the
node is made up from the name of the containing control (sometimes prefixed
by the master page container control name), a "t", and a private index number
of the TreeNode.

You can get around this, but you end up limiting the current functionality
of the tree node.

To enable changing of the node text on the client side, create a new class
that inherits from the TreeNode. Override the RenderPreText method and add
the following code:

protected override void RenderPreText(HtmlTextWriter writer)
{
writer.WriteBeginTag("a");
writer.WriteAttribute("id", "a" + this.ValuePath);
writer.Write("This is the node text! Awesome!");
writer.Write(HtmlTextWriter.SelfClosingTagEnd);
base.RenderPreText(writer);
}
If you don't set the TreeNode.Text value, then this tag will be all the user
sees.
This puts an additional anchor tag in the treenode with an id (a +
node.ValuePath) that you can determine programatically at run time. In order
for the TreeView to use this (let's call it) AdvancedTreeNode, you also have
to create a new AdvancedTreeView that extends the TreeView. Override the
CreateNode method that creates a new AdvancedTreeNode and returns it
(implicitly cast to a TreeNode) thusly:

protected override TreeNode CreateNode()
{
return new AdvancedTreeNode(this, false);
}

You can alter the AdvancedTreeNode's new anchor tag so that it performs all
the required javascript calls via this new anchor tag. Use Lutz Roeder's
..NET Reflector to view the render method of the original TreeNode (or just
look at the DOM) to find out what javascript calls you should make when the
node is clicked on, etc.

To remove the node, you can just go up the family tree to the table that
contains both the new anchor tag and the old one and work your magic on that.
This method also allows you to scroll to a particular node -- just scroll to
the element with an ID of "a"+node.ValuePath!

"Daves" wrote:
Sorry folks but I will be reposting this question from 6/5 until someone
gives me an answer - the question is very easy and so ought the answer to
be. I really need the answer!

-------
I'm sorry for reposting but I've already googled for hours and I see others
have asked about this here without getting replies, this is starting to look
like some Bermuda phenomenon nobody wants to answer to! I really need to
accomplish the task below...

---
Is there any documentation out there to find out if and then how I can work
with TreeView on client side through jscript? For example I want to change
title of nodes and remove without doing postback. MS doesn't seem to have
any official documentation on this.

And please notice I'm not refering to IE TreeView control but asp.net 2.0's
TreeView!

Jun 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mad Scientist Jr | last post by:
i am trying to set focus to a specific control depending on the outcome of a validator control and it is not working. none of these methods are working to setfocus: 1....
3
by: Larry David | last post by:
Hi, I'm just trying to wrap my mind around the ASP.NET model. Let me walk you through a trivial scenario: Let's say I have a form containing a text box where the user enters his name. It also...
7
by: RFS666 | last post by:
Hello, I would like to use variables with a type in jscript.NET. I declare them as follows: var x : double = 5.03; This doesn't work in my script, that I write to the page in codebehind with...
3
by: Daves | last post by:
is there any documentation out there to find out if and then how I can work with TreeView on client side through jscript? For example I want to change title of nodes and remove without doing...
0
by: Daves | last post by:
I'm sorry for reposting but I've already googled for hours and I see others have asked about this here without getting replies, this is starting to look like some Bermuda phenomenon nobody wants to...
0
by: Daves | last post by:
Sorry guys but I will be reposting this question from 6/5 until someone gives me an answer - the question is very easy and so ought the answer to be. I really need the answer! ------- I'm sorry...
1
by: Victor Rodriguez | last post by:
Is there a way that I can have a client side event like oncontextmenu="showfunction();" on each node? thanks, Victor
8
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
1
by: sermet | last post by:
Hi everybody, I have an application that works for IE. I used treeview.htc to create a tree view. And I want my client side code to work with linux based operating systems. So the code should work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.