all groups > asp.net > may 2005 >
You're in the

asp.net

group:

Problem showing confirm dialog on button webcontrol's onclick even


Problem showing confirm dialog on button webcontrol's onclick even Tarun Upadhyaya
5/31/2005 10:09:01 PM
asp.net:
Hi,
I am facing strange problem
I read Scott mitchell's article about ASP.NET and javascript at

http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/clientsidescript.asp

where he has talked about creating a base class for displaying alerts and
confirms after and before postbacks respectively.

I used that Base class to inherit on of my code behind classes and and i
also called the method to attach a confirm (javascript method ) script on a
button's onclick event .
The page works fine so long as there are no validations on the page but as
soon as i incorporate validations the confirm box still apears but the page
validations are skipped and the form is posted back.

This happnes since asp.net also inserts some code for validation after my
code for client side validation methods
it looks somethings like this

onclick='return confirm(message);if (typeof(Page_ClientValidate) ==
'function') Page_ClientValidate(); '

I feel is somehow i can insert my confirm script after the code inserted by
asp.net , then propably my problem is solved.


Please help.

Thanks and Regards

Tarun Upadhyaya
MCP (VB.NET & SQL Server 2000)
Re: Problem showing confirm dialog on button webcontrol's onclick even Peter Blum
6/1/2005 1:56:52 PM
Let's change your logic slightly:

onclick='if (!confirm(message)) return false;if (typeof(Page_ClientValidate)
== 'function') Page_ClientValidate(); '

--- Peter Blum
www.PeterBlum.com
Email: PLBlum@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tarun Upadhyaya" <t a r u n u p a d h y a y a @ y a h o o . c o . i n>
[quoted text, click to view]

Re: Problem showing confirm dialog on button webcontrol's onclick Tarun Upadhyaya
6/1/2005 10:21:03 PM
Oh man, that was so simple.
Thanks a lot Mr Blum.
I had seen you validation controls and beleive me, they are rocking.

Thanks again you have saved many days.


--
Tarun Upadhyaya
MCP (VB.NET & SQL Server 2000)
NB: If you find my post helpful pls click the yes button on top.


[quoted text, click to view]
Re: Problem showing confirm dialog on button webcontrol's onclick Peter Blum
6/2/2005 12:19:42 PM
You are welcome, Tarun. My validation controls support a confirm prompt
feature too. If you are trying to save time, having tools that avoid custom
coding and hacks will really help.

--- Peter Blum
www.PeterBlum.com
Email: PLBlum@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tarun Upadhyaya" <t a r u n u p a d h y a y a @ y a h o o . c o . i n>
[quoted text, click to view]

AddThis Social Bookmark Button