views:

395

answers:

1

I have a simple javascript (JQuery based) method that does some css magic to show/hide some divs when a user submits a .net web form

function doShowHide()
{
  $('.Button').hide();
  $('.ButtonHdn').show();
}

I'm using the built in .net control validation, so I need the WebForm_DoPostBackWithOptions() method to run in addition to the js snippet above. The sequence, however, is what I'm having issues with. I need the validation to take place (and be valid) before my js code above fires (I don't want to hide the button if the page isn't valid).

Any suggestions would be much appreciated.

My end goal is to have a the submit button go away (on successful validation) and be replaced with another button that is disabled and says "Please Wait...". I've Google'd the issue but everyone seems to have the issue, but no one has a simple answer. The community here always has the best answers, so I thought I'd post my issue here.

Thanks!

+1  A: 

If you nee to execute the javascript function after the server side code is executed then you can use

Page.ClientScript.RegisterStartupScript()

See msdn article.

rahul
The easiest solution is to use this and have inside your PageLoad method outside of the if (Page.IsValid) block for it to inject jquery into the page to unhide the button.
Chris Marisic