RadioButton AutoPostBack does not execute JavaScript

Discussion in 'ASP .Net' started by M, Mar 26, 2005.

  1. M

    M Guest

    Hi everybody,

    I have a Web form with something like:
    <form id="Form1" method="post" onsubmit="javascript:submitForm();"
    runat="server">

    I need the JavaScript function submitForm() to execute everytime the form is
    submitted.

    I also have two RadioButtons with AutoPostBack set to true.

    The problem is when I click on one of the radio button, the form is posted
    back, but the JavaScript is not executed. Is there a way to get some
    JavaScript to execute everytime the Web form is posted back?

    Thanks in advance.
     
    M, Mar 26, 2005
    #1
    1. Advertising

  2. M

    JustinBlat Guest

    The radio buttons you are using do not submit the form the same way a
    button does. The OnSubmit event of the form object only fires when a
    button of type Submit fires the event. When a radio button ( or
    checkbox, or dropdownlist) is set to autopostback, that postback occurs
    via the __doPostback function generated automatically by ASP.NET. This
    function takes an eventTarget and an eventArgument, and posts this data
    back to the sever. To see an example of this, view the HTML source on
    your page. One way to get around this problem is to override the
    __doPostback event in javascript, and execute your script from there.
    One such example can be found here:

    http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInWhidbey.aspx

    Hope this has been helpful, Good Luck!
     
    JustinBlat, Mar 27, 2005
    #2
    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. Brian Miller
    Replies:
    6
    Views:
    2,998
    Brian Miller
    Nov 27, 2004
  2. Mick
    Replies:
    2
    Views:
    7,213
    Saravana
    Jan 5, 2005
  3. Brano
    Replies:
    3
    Views:
    12,329
    rpundlik
    Feb 14, 2010
  4. Carlos
    Replies:
    1
    Views:
    351
  5. Savas Ates
    Replies:
    1
    Views:
    304
    Patrice
    Aug 17, 2004
Loading...

Share This Page