Stop a postback in javascript

后端 未结 4 1257
执念已碎
执念已碎 2021-01-06 10:51

i have an ASP webform with a JQuery Thickbox, i have an image that opens the thickbox when user click.

once open the thickbox it shows me a grid with several rows an

相关标签:
4条回答
  • 2021-01-06 10:56

    How I do it; How I've done it:

    <asp:LinkButton ID="linkKB" OnClientClick="absolutizeWidth(); return false;"  runat="server">Columns too small?</asp:LinkButton>
    

    The "return false" stops the postback of the server control after the javascript function executes. Very useful.

    0 讨论(0)
  • 2021-01-06 10:58

    hmmm let me try.. (i dont speak english and dont know the correct words to explain that i want but ill try :P)

    i call a javascript __doPostBack BUT it takes too much to respond and stay in Loading... i want to stop the postback, something like a response.end but in javascript.

    if my script takes too much to execute then call a StopPostBack or something..

    thanks.

    0 讨论(0)
  • 2021-01-06 11:02

    To stop postback in javascript, write a "return false;" statement.

    But i guess i just didn't understand your question or you asked it too unclear. :)

    0 讨论(0)
  • 2021-01-06 11:14

    Are you trying to stop the post back after you refresh the page or after the Thickbox returns?

    If you do not want to execute the postback when the user fires off an event, you can just return false within that even handler.

    For example, the normal way to stop posting back during a page load is something like this:

    onClick="if(SOMECONDITION != true) { return false; }" 
    

    This will stop the postback being fired.

    If a postback is already in progress and you want to try and abort it (which I think is what you are asking), you will need to "stop" the page from loading (as that's what the javascript is doing). Maybe try this:

    IE: window.document.execCommand('Stop'); Other (Mozilla etc): window.stop();

    I haven't tried this in a while (and it's off the top of my head), so the code may need some massaging.

    If I've totally missed your question, I apologise, maybe you can clarify?

    0 讨论(0)
提交回复
热议问题