Search code examples
asp.netonsubmitautopostbackselectedindexchanged

ASP.NET AutoPostBack for SelectedIndexChanged fires form's onsubmit script


Since upgrading from .NET 1.1 to 4.0 I have a problem with a form.

The form has some dropdowns with AutoPostBack=true because they have some SelectedIndexChanged handlers that need to fire to populate other dropdowns, etc.

But now, when a new value is selected in the dropdown, it fires the onSubmit script specified in the form tag:

<form id="Form1" method="post" runat="server" onsubmit="return jvsValidate() ;">

Where before, that would only fire when the button control was clicked:

<asp:button id="btnRoute" runat="server" text="Save"></asp:button>

What's the best way to rectify this?


Solution

  • remove from onsubmit="return jvsValidate() ;" in form tag and update syntax with button like below

    <asp:button id="btnRoute" runat="server" text="Save" OnClientClick="return jvsValidate();" ></asp:button>