Conditional Client Side and Server Side call same button

I have a submit button on a form that I want to first do the validation and if valid call a client side javascript function and then run through its click event handler 

currently I have this set up by adding this line in the Page_Load

mybutton.Attributes.Add("onclick", "javascript:ShowRunningDialog(this);");

But if the page is not valid I don't want to call this client side function. As it is now the 'ShowRunningDialog' is obviously going to be called no matter what
 

 

 

0
migo
12/14/2007 2:10:07 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
1332 Views

Similar Articles

[PageSpeed] 39
Get it on Google Play
Get it on Apple App Store

 if (Page.IsValid) mybutton.Attributes.Add("onclick", "javascript:ShowRunningDialog(this);");

Was that what you meant? 


Please Mark As Answer posts that helped you.

"If we learn from our mistakes, I should be brilliant by now."

0
nikki_doer_of_things
12/14/2007 2:30:19 PM

 Duh. Perfect. Thanks.

0
migo
12/14/2007 3:01:25 PM

You still need to post back which is unnecessary.  This can be done using all JavaScript see the following:

 

function ShowValid()

{

    ValidatePage();

    if(Page_IsValid)

        //Do Something

    else

        return false;

0
scott976
12/14/2007 5:45:44 PM
Reply: