Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Strange doubt javascript:confirm

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo Roberto - 01 Aug 2007 23:37 GMT
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!
Paulo Roberto - 01 Aug 2007 23:58 GMT
on my work machine works well, but on my home machine doesnt... both are XP
PRO SP 2

> 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
[quoted text clipped - 4 lines]
>
> Thanks!
Göran Andersson - 02 Aug 2007 00:41 GMT
> 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
[quoted text clipped - 4 lines]
>
> 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?');"

Signature

Göran Andersson
_____
http://www.guffa.com

Paulo Roberto - 02 Aug 2007 00:44 GMT
> 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?
Göran Andersson - 02 Aug 2007 11:47 GMT
>> 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?

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

Signature

Göran Andersson
_____
http://www.guffa.com

Mark Rae [MVP] - 02 Aug 2007 00:52 GMT
> What can be the problem ? IE versions ?

Incorrect syntax is your problem...

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

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.