473,473 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Treeview node, add confirm javascript?

Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit" and a "delete"
node. I have the functionality of the edit and delete working fine, my
issue is now however that I cannot seem to find a way to add an
"onclick" event that fires a confirm box. I've tried this method..

treenode.Text = "<a href=""javascript:confirm('confirm text') return
true;"">text</a>"

and that fires a confirm, but does nothing when i click on "ok", in
other words it doesn't delete the project when i confirm.

Can anyone lend a hand here? Thanks in advance!

- Jeff

Aug 25 '06 #1
4 10007
Hi,

tfsmag wrote:
Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit" and a "delete"
node. I have the functionality of the edit and delete working fine, my
issue is now however that I cannot seem to find a way to add an
"onclick" event that fires a confirm box. I've tried this method..

treenode.Text = "<a href=""javascript:confirm('confirm text') return
true;"">text</a>"

and that fires a confirm, but does nothing when i click on "ok", in
other words it doesn't delete the project when i confirm.
First, you should never ever use the javascript: pseudo protocol in a
HREF. That is known to cause problems. Check comp.lang.javascript on
Google News for details.

Second, of course the code above does nothing. You ignore the return
value of the "confirm" function. confirm() returns true if OK was
clicked, false otherwise.

Finally, you return true in your HREF, but that doesn't help anything.
What do you want to achieve if the user clicks OK? Call a URL? If yes,
that should be:

treenode.Text = "<a href=""aUrl.html"" onclick=""return confirm('confirm
text');"">text</a>"

Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 25 '06 #2
thanks laurent, i'm pretty bad with javascript... i'll try your code
out and see how it goes.

cheers,
Jeff

Laurent Bugnion wrote:
Hi,

tfsmag wrote:
Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit" and a "delete"
node. I have the functionality of the edit and delete working fine, my
issue is now however that I cannot seem to find a way to add an
"onclick" event that fires a confirm box. I've tried this method..

treenode.Text = "<a href=""javascript:confirm('confirm text') return
true;"">text</a>"

and that fires a confirm, but does nothing when i click on "ok", in
other words it doesn't delete the project when i confirm.

First, you should never ever use the javascript: pseudo protocol in a
HREF. That is known to cause problems. Check comp.lang.javascript on
Google News for details.

Second, of course the code above does nothing. You ignore the return
value of the "confirm" function. confirm() returns true if OK was
clicked, false otherwise.

Finally, you return true in your HREF, but that doesn't help anything.
What do you want to achieve if the user clicks OK? Call a URL? If yes,
that should be:

treenode.Text = "<a href=""aUrl.html"" onclick=""return confirm('confirm
text');"">text</a>"

Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 25 '06 #3
nope.. that still didn't work... when placing javascript inside of the
text attributes, it is overriding the treenode_click event with what's
in the javscripts onclick event. Anyone else have any ideas?
tfsmag wrote:
thanks laurent, i'm pretty bad with javascript... i'll try your code
out and see how it goes.

cheers,
Jeff

Laurent Bugnion wrote:
Hi,

tfsmag wrote:
Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit" and a "delete"
node. I have the functionality of the edit and delete working fine, my
issue is now however that I cannot seem to find a way to add an
"onclick" event that fires a confirm box. I've tried this method..
>
treenode.Text = "<a href=""javascript:confirm('confirm text') return
true;"">text</a>"
>
and that fires a confirm, but does nothing when i click on "ok", in
other words it doesn't delete the project when i confirm.
First, you should never ever use the javascript: pseudo protocol in a
HREF. That is known to cause problems. Check comp.lang.javascript on
Google News for details.

Second, of course the code above does nothing. You ignore the return
value of the "confirm" function. confirm() returns true if OK was
clicked, false otherwise.

Finally, you return true in your HREF, but that doesn't help anything.
What do you want to achieve if the user clicks OK? Call a URL? If yes,
that should be:

treenode.Text = "<a href=""aUrl.html"" onclick=""return confirm('confirm
text');"">text</a>"

Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 27 '06 #4
Okay i finally figured it out... Here is how i got it to work

Dim deletenode As New TreeNode("<span onclick=""javascript:confirm('Are
you sure you want to delete " & dr("ProjectName") &
"?');"">Delete</span>", "0" & dr("ProjectID"))

This made it work correctly and still fire the SelectedNodeChanged
event. I had to use a <spantag because when i used a normal <a href>
it would override the SelectedNodeChanged event. Simple solution it
seems, but man did it take me awhile to figure out!
tfsmag wrote:
nope.. that still didn't work... when placing javascript inside of the
text attributes, it is overriding the treenode_click event with what's
in the javscripts onclick event. Anyone else have any ideas?
tfsmag wrote:
thanks laurent, i'm pretty bad with javascript... i'll try your code
out and see how it goes.

cheers,
Jeff

Laurent Bugnion wrote:
Hi,
>
tfsmag wrote:
Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit" and a "delete"
node. I have the functionality of the edit and delete working fine, my
issue is now however that I cannot seem to find a way to add an
"onclick" event that fires a confirm box. I've tried this method..

treenode.Text = "<a href=""javascript:confirm('confirm text') return
true;"">text</a>"

and that fires a confirm, but does nothing when i click on "ok", in
other words it doesn't delete the project when i confirm.
>
First, you should never ever use the javascript: pseudo protocol in a
HREF. That is known to cause problems. Check comp.lang.javascript on
Google News for details.
>
Second, of course the code above does nothing. You ignore the return
value of the "confirm" function. confirm() returns true if OK was
clicked, false otherwise.
>
Finally, you return true in your HREF, but that doesn't help anything.
What do you want to achieve if the user clicks OK? Call a URL? If yes,
that should be:
>
treenode.Text = "<a href=""aUrl.html"" onclick=""return confirm('confirm
text');"">text</a>"
>
Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.
>
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 27 '06 #5

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

Similar topics

0
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
1
by: JustinG | last post by:
I am relativley new to C#, and I am trying to write code using the compact framework, that will allow a handheld user to hit enter while a treeview node is selected, which will then do something...
0
by: Devhead | last post by:
I changed the treeview node text to bold and changed color "successfully". However, the node text was truncated and when i did a tree refresh the node formatting was gone. What do i need to do to...
6
by: Tim | last post by:
Hi I have a form with a treeview on it. When I select a particular node it adds/shows a tab on the form. The treeview node remains selected as it should. The user can close the tab or remove the...
4
by: Yavuz Bogazci | last post by:
Hi, i have created a treeview and this works nice. I have now a problem: I want to store 2 more Information to each Treeview Node like UserID and CompanyID. How can i do that? Thanks Yavuz...
8
by: Don Wash | last post by:
Hi There! I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView. We used to have "Key" property in TreeView node...
2
by: Christian Rühl | last post by:
heyho, guys! here's another question for you now: i built an iterator to get all the nodes with a certain attribute in an xml dom. it all looks like this (i'm using .NET framework 1.1) ...
3
by: Michael_Burgess | last post by:
Hi there, I've looked around the different groups and still can't figure this out without resorting to scrappy code............ I want to programtically select and highlight a TreeView node,...
1
by: R.A.F. | last post by:
Hi, I would like simulate a mouse click on on of my treeview nodes when my form opens. for that i was thinking to use the same simple way as under C++ : SendMessage(TreeView.Nodes.Handle,...
0
by: Zuhaib Hyder | last post by:
TreeView node selection not working with PopulateOnDemand, any idea?? i want to select each node on click... even when any file opens in right frame in response of click on Treeview node on left...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.