ASP.NET 1.X for ASP.NET 2.0: Reverse side validation breaking

Good afternoon,

We have migrated our web application to ASP.NET 2.0 from ASP.NET 1.1.

We have a page that contains several text fields with their respective validators.

In .NET 1.1, when the text field contains INVALID, pressing the submit button will not return a message (EG Nothing will happen).

However, when we migrated to .NET 2.0, even if there is an INVALID value, the postback will still happen. (EG Pressing the submit button will do the postback).

Is there a validation issue when going from 1.1 to 2.0?

Additional information: The "submit" button is an enter button:

<input type="button">

      

Using it <asp:button>

instead of a button <input>

will work and fix the problem. However, it <input type="button">

has the ability to call javascript, which will call the "Wait ... Loading" label on the page. Using the asp: button, "Waiting ... Loading" of the javascript overlay will NOT be called.

EDIT: real problem and solution.

Anyway, the real problem is that the validation check JavaScript was broken during the 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 my solution changed to INPUT button to ASP button: then add an attribute that makes the page load with correct ASP.NET 1.1 JavaScript validation like this:

m_bt_Save.Attributes.Add("OnClick", "if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate()) __doPostBack('m_bt_Save','')");

      

0


a source to share


3 answers


One thing you can do is just add your own JS that you need for the button.

Button1.Attributes.Add("OnClick", "do my js stuff here");

      



This will allow you to have the same functionality as the input and this makes it work.

Otherwise, I am guessing that you will need to change the input method of the enter button to call the validation method before it submits.

+1


a source


+1


a source


This happened in our update too. I think we've narrowed it down to an issue with the WebUIValidation.js file. I think reinstalling was the final solution for us.

0


a source







All Articles