javascript - Stop page reload of an ASP.NET button -


net application, have inserted button call javascript function (onclientclick event) , vb.net function (onclick event)

<asp:button onclientclick="jsfunction() " onclick="vbfunction" text="submit" runat="server" /> 

the problem when click button, refreshes page , delete content of text boxes.

i have tried inserting return false; on onclienclick event, doesn't execute onclick event.

how can avoid page reload ?

p.s.: @ end of javascript function new window opened window.open(newwindow.aspx), want first page mantain value inserted user in text boxes.

thanks in advance :)

you need use return statement @ 2 points.

onclientclick="return jsfunction();"  function jsfunction() {   //   return false; } 

or, you can return false after function call this.

onclientclick="jsfunction(); return false;" 

note if want postback conditionally need return true or false.

onclientclick="return jsfunction();"  function jsfunction() {   if(conditionforpostback)       return true;   else       return false; } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -