473,385 Members | 2,044 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,385 software developers and data experts.

TreeView 2.0

Is there a way that I can have a client side event like
oncontextmenu="showfunction();" on each node?

thanks,

Victor
Aug 24 '06 #1
1 3627
Hi Victor,

As for the ASP.NET 2.0 Treeview, it is a new control which targeting
multiple web browsers unlike the original IE WebControl TreeView.
Therefore, it may lack many client-side rich behaviors like the IE
webcontrol TreeView.

Currently, for the ASP.NET 2.0 TreeView, we can not add client-side scritp
handler for individual TreeNode(the treenode is not a child control, but a
normal class). What we can do is add a client-side handler for the TreeView
control. e.g.

==================
<asp:TreeView ID="TreeView1" runat="server"
oncontextmenu="javascript:treeview_oncontextmenu() ;return false;" >

or

protected void Page_Load(object sender, EventArgs e)
{

TreeView1.Attributes["oncontextmenu"]="javascript:treeview_oncontextmenu();r
eturn false;";
}
===================
Then, this event will be triggered when you right click on any part of the
TreeView(the same for any other client events like "onclick" .....). If you
want to trigger the exact individual TreeNode which trigger the event, we
need to add some additional script code to detect whether the event is
raised by a TreeNode(each treenode by default is rendered as an html link
<ain the page's output). here is a test script function which detect
which TreeNode is right clicked and display its "internal id" and
"TreeNodeName":

=========================
<script language="javascript">
function treeview_oncontextmenu()
{
var obj = window.event.srcElement;

if(obj.tagName == "A")
{
alert("id: " + obj.id + ", name: " + obj.innerHTML);
}

}
</script>
========================

I get this idea from the following article, I think it will be helpful to
you:

#ASP.NET 2.0 Treeview Checkboxes - Check All - Javascript
http://harishmvp.blogspot.com/2006/0...boxes-check.ht
ml

BTW, due to the limitation of the current implementation of ASP.NET
TreeView control, we could only get the TreeNode's id or name information,
but can not manipulate it like server-side code.

Hope this helps.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 25 '06 #2

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

Similar topics

42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
5
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a...
1
by: paradox | last post by:
I want to have a TreeView that shows an image on some items, but not all. Basically, if a certain condition is true, a caution icon is placed next to the treeview item. The problem is that, by...
3
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%""...
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
14
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
3
by: christof | last post by:
I've got a really easy problem, please help me: There are two pages in one I'm creating a TreeView like that: TreeView dbTree = new TreeView(); TreeNode dbTreeRoot = new TreeNode("Root");...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
1
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.