autopostback - javascript intercept and cancel

Discussion in 'ASP .Net' started by Susan van Houen, Jul 17, 2003.

  1. 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, Jul 17, 2003
    #1
    1. Advertisements

  2. 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
     
    Sreejumon[MVP], Jul 17, 2003
    #2
    1. Advertisements

  3. Susan van Houen

    Marina Guest

    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.
     
    Marina, Jul 17, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.