autopostback - javascript intercept and cancel

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default autopostback - javascript intercept and cancel

    Hi All,

    How do I intercept an autopostback on the client side
    and prevent it from executing the submit?

    In classic ASP I used to intercept the on_submit and
    just

    return false;

    but it doesn't seem to work anymore.

    Any ideas?

    Sincerely,
    S


    Susan van Houen Guest

  2. Similar Questions and Discussions

    1. How to intercept property changes in subclassed control?
      I've got an application that uses constants stored in XML files (see attached). The XML files are loaded into mx:Models and used as dataProviders on...
    2. Intercept when my control dropped on a WebForm
      Hi All! I need to intercept the event when my control dropped on a WebForm (or manually added by changin page's source HTML). I know about...
    3. HttpWebResponse intercept raw HTTP?
      For diagnostic and learning purposes, I would like to intercept and log the raw HTTP headers and content from a HttpWebResponse in a webservice. ...
    4. How to intercept an event in ASP.NET?
      You can override the RaisePostBackEvent method of the Page class. The first parameter sent to this method is the object that caused the postback....
    5. WEBFORM: can I intercept Back and...
      Roby, HTTP is connectionless. Therefore, you have no way of intercepting client-side events from server-side code. Jim Cheshire Developer...
  3. #2

    Default autopostback - javascript intercept and cancel

    Hi Susan,

    Please add the javascript function to your server control
    as given below.
    Button1.Attributes.Add("onclick", "return FunctionName
    ();");

    Now put the function in html section. If success then you
    can return true else false.

    So it wont submit the page if client side function fails.

    Let me know if you ned furtehr help.
    Regards
    Sreejumon

    >-----Original Message-----
    >Hi All,
    >
    >How do I intercept an autopostback on the client side
    >and prevent it from executing the submit?
    >
    >In classic ASP I used to intercept the on_submit and
    >just
    >
    > return false;
    >
    >but it doesn't seem to work anymore.
    >
    >Any ideas?
    >
    >Sincerely,
    >S
    >
    >
    >.
    >
    Sreejumon[MVP] Guest

  4. #3

    Default Re: autopostback - javascript intercept and cancel

    The reason that doesn't work, is because by setting AutoPostBack to true,
    that generates an onselectedindexchanged handler, which just submits the
    form. So the one you created, just get ignored.

    I would instead suggested that you turn autopostback to false, and just keep
    your handler. This handler should then sometimes manually submit the form by
    calling its submit method.

    "Susan van Houen" <svhouen@hotmail.com> wrote in message
    news:uEdR89JTDHA.2196@TK2MSFTNGP12.phx.gbl...
    > Thank you for your response, but I can't get it to work.
    >
    > My control looks like this
    > <asp:dropdownlist id="ddlPoi" style="Z-INDEX: 125; LEFT: 32px; POSITION:
    > absolute; TOP: 445px" runat="server"
    > OnSelectedIndexChanged="lbLocoptions_SelectedIndex Changed"
    > AutoPostBack="True">
    >
    > When OnSelectedIndexChanged is fired I want it to pass through a client
    side
    > javascript where I can evaluate if I actually want the autopostback to
    > complete or not.
    >
    > In the Page_Load of the behind code I have
    >
    > lbLocoptions.Attributes.Add("onselectedindexchange d", "return
    > lbLocoptions_onchange();")
    >
    > and in the client I have
    >
    > function lbLocoptions_onchange(){
    > return false;
    > }
    >
    > Still, the AutoPostBack completes every time.
    >
    > Sincerely,
    > S
    >
    > "Sreejumon[MVP]" <sreeju_uss@hotmail.com> wrote in message
    > news:016301c34c9b$1faf4d50$a601280a@phx.gbl...
    > > Hi Susan,
    > >
    > > Please add the javascript function to your server control
    > > as given below.
    > > Button1.Attributes.Add("onclick", "return FunctionName
    > > ();");
    > >
    > > Now put the function in html section. If success then you
    > > can return true else false.
    > >
    > > So it wont submit the page if client side function fails.
    > >
    > > Let me know if you ned furtehr help.
    > > Regards
    > > Sreejumon
    > >
    > >
    > > >-----Original Message-----
    > > >Hi All,
    > > >
    > > >How do I intercept an autopostback on the client side
    > > >and prevent it from executing the submit?
    > > >
    > > >In classic ASP I used to intercept the on_submit and
    > > >just
    > > >
    > > > return false;
    > > >
    > > >but it doesn't seem to work anymore.
    > > >
    > > >Any ideas?
    > > >
    > > >Sincerely,
    > > >S
    > > >
    > > >
    > > >.
    > > >
    >
    >

    Marina Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139