firing client validation before client confirmation in asp.net

Client Side Confirmation is simple one using Java Script, Just write this single line in OnClienClick Properties of your Submit Button and set up Client Confirmation Box at Button Click Event.


return confirm('Do you want add this Problem?');


Now, when you have Java Script validation in your page this kind of Client Confirmation will create difficulties. More specifically, at Button Click Confirmation Box will will appear first, if client click Ok Button, Web Page will be submitted to server skipping Client Side Validation.

So, all we need to do is to fire Client validation prior to Client Confirmation and if Client Validation returns True then generate Client Confirmation. I found this Java Script function to do this.


    function ConfirmSubmit() {
      
        Page_ClientValidate();

        if (Page_IsValid) {

            return confirm('Do you want add this Problem?');

        }
        
        return Page_IsValid;
    }


Call this function at OnClienClick Properties of Submit Button.


return ConfirmSubmit();

Thanks
A Rahim Khan

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: