views:

36

answers:

1
<input type="button" name="reset"
       onclick="return ValidateValue(); __doPostBack('ApplyBtn','')" />

The above is the code generated for asp server button button control on browser.

Now my query is that irrespective of ValidateValue() returning true/false __doPostBack('ApplyBtn','') function is not showing any effect for me.

My understanding is that string passed to onclick acts like function body, and return will from first function will return control preventing second function from execution. Is that correct ?

Please provide helpful inputs.

+3  A: 

Your understanding is correct...and it's easily fixed :), instead of this:

return ValidateValue();

Do this:

if(!ValidateValue()) return false;

This way you only abort early if there is a reason to abort, otherwise you continue executing the rest.

Nick Craver
wow amazing fix :D thanks man thanks a lot
Anil Namde