Strange doubt javascript:confirm

P

Paulo Roberto

Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... It´s a very strange problem because to my knowledge
it´s a client feature... What can be the problem ? IE versions ?

Thanks!
 
P

Paulo Roberto

on my work machine works well, but on my home machine doesnt... both are XP
PRO SP 2
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Paulo said:
Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
javascript:confirm('are you sure delete record?') on gridview at
rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
does nothing... but on my machine at HOME, even when I click cancel it
deletes the records... It´s a very strange problem because to my knowledge
it´s a client feature... What can be the problem ? IE versions ?

Thanks!

Don't use the javascript: protocol when you aren't putting the
Javascript in an URL.

The event expects a return value from the code, which is used to
determine if the action should be canceled or not.

So, the correct code is:

OnClientClick="return confirm('are you sure delete record?');"
 
P

Paulo Roberto

So, the correct code is:
OnClientClick="return confirm('are you sure delete record?');"


Göran, my code is the same as yours and works only on my machine at work...
Any suggestion?
 
M

Mark Rae [MVP]

What can be the problem ? IE versions ?

Incorrect syntax is your problem...

OnClientClick="return confirm('Are you sure you want to delete this
record?');"
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Paulo said:
Göran, my code is the same as yours and works only on my machine at work...
Any suggestion?

Have you examined the generated code to see if there are any differences?
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top