javascript : catch a click before asp net

C

c.triffault

Greetings,

I got a usercontrol which generates LinkButton objects. I want that
when the user click on it, a "confirm" javascript is generated.
After reading
http://groups.google.co.uk/group/mi...avascript+&qt_g=1&searchnow=Search+this+group

I did this :

deleteLink.Attributes["onclick"]="confirmCustom(this)";

in my aspx page, I got a function named confirmCustom :

function confirmCustom(source)
{

answer = confirm("are you sure ? ");

if (answer==false) {
temporaryHref = source.href;
source.href="#";
}
}


My javascript knows what link have been clicked with the "this"
reference.
My problem is that the program doesn't care whether you answer yes or
no : it just proceeds with the href reference after returning from my
function.

I thought of storing the href property in a temporary variable and
restore it later but this seems ugly to me (and not sure to make it
work either :) ).

And yes, I need a Hyperlink control :)

Many thanks for your help
 
A

Alvin Bruney - ASP.NET MVP

your javascript is incomplete. Amend it to return a boolean variable based
in the selection. That will stifle the event bubble.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
C

charly

weird because I had tried this :

return (confirm("do you confirm")

which returns true if the user clicks ok and false otherwise.

Can you confirm this behaviour on IE 6 ?

Many thx for answering though
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top