Catching Submit Event even called by document.forms[0].submit()

Discussion in 'ASP .Net' started by The Crow, Sep 27, 2005.

  1. The Crow

    The Crow Guest

    i have to catch submit event of the form contained in the asp.net webform.
    when a button on the page clicked, it works ok, but when i call
    form.submit() or linkbutton vs. calls __doPostBack() , form.onsubmit()
    doesnt rise..
    The Crow, Sep 27, 2005
    #1
    1. Advertising

  2. if (Page.IsPostBack)
    {
    }

    If Page.IsPostBack is true, the form has been submitted.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    I'd rather be a hammer than a nail.

    "The Crow" <q> wrote in message
    news:...
    >i have to catch submit event of the form contained in the asp.net webform.
    >when a button on the page clicked, it works ok, but when i call
    >form.submit() or linkbutton vs. calls __doPostBack() , form.onsubmit()
    >doesnt rise..
    >
    Kevin Spencer, Sep 27, 2005
    #2
    1. Advertising

  3. The Crow

    Bruce Barker Guest

    the browser doesn't raise the onsubmit event if form.submit() is called.
    when you do a submit try:

    function mySubmit()
    {
    var frm = document.forms[0];
    if (frm.onsubmit) frm.onsubmit();
    frm.submit();
    }

    you will need to replace the __doPostBack(). just register a startup script
    block like:

    window.__doPostBack = function (eventTarget, eventArgument)
    {
    var frm = document.forms[0];
    frm .__EVENTTARGET.value = eventTarget.split("$").join(":");
    frm .__EVENTARGUMENT.value = eventArgument;
    mySubmit();
    }

    note: if you use subforms then use the form name instead of 0

    -- bruce (sqlwork.com)


    "The Crow" <q> wrote in message
    news:...
    >i have to catch submit event of the form contained in the asp.net webform.
    >when a button on the page clicked, it works ok, but when i call
    >form.submit() or linkbutton vs. calls __doPostBack() , form.onsubmit()
    >doesnt rise..
    >
    Bruce Barker, Sep 27, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lars Netzel
    Replies:
    3
    Views:
    424
    Greg Burns
    Jul 22, 2004
  2. Helen
    Replies:
    1
    Views:
    468
    Eliyahu Goldin
    Aug 17, 2004
  3. Stan Goodman

    Even older fart, even newer newbie

    Stan Goodman, Jul 3, 2003, in forum: Java
    Replies:
    11
    Views:
    670
    Stan Goodman
    Jul 4, 2003
  4. S_K
    Replies:
    6
    Views:
    1,156
    Robert Dunlop
    Nov 8, 2007
  5. Harry
    Replies:
    3
    Views:
    339
    Harry
    Jan 12, 2006
Loading...

Share This Page