Good Day,
We have migrated our web application to ASP.NET 2.0 from ASP.NET 1.1.
We have a page that contains a couple of textboxes with their respective Validators.
On .NET 1.1, when a textbox contains an INVALID value, clicking on the "submit" button, will not produce a postback (E.G. Nothing will happen).
However, when we migrated to .NET 2.0, even if there is an INVALID value, the postback will still happen. (E.G. Pressing the "submit" button will perform a postback).
Is there an issue with validation when migrating from 1.1 to 2.0?
Additional Infos: The "submit" button is an input button:
<input type="button">
Using an <asp:button>
in place of the <input>
button will work and will fix the problem. However, the <input type="button">
has the capability to call a javascript that will produce a "Wait... Loading" label overlay on the page. Using the asp:button, the "Wait... Loading" overlay javascript will NOT be invoked.
EDIT: Real problem and solution.
Anyway, the real problem is that the on-click validation javascript was broken during migration.
The original and working script is:
<input language="javascript" onclick="{if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) __doPostBack('m_bt_Save','')} " name="m_bt_Save" id="m_bt_Save" type="button" value="Save" width="80px" height="24px" />
But ASP.NET 2.0 changed it to:
<input onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(''); __doPostBack('m_bt_Save','')" name="m_bt_Save" type="button" id="m_bt_Save" value="Save" width="80px" height="24px" />
So the my solution was, change the INPUT button to an ASP:button, then add the attribute doing page load with the correct ASP.NET 1.1 javascript validation like so:
m_bt_Save.Attributes.Add("OnClick", "if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) __doPostBack('m_bt_Save','')");