Wednesday, May 20, 2009

How to know Page.IsValid on Client Side in Asp.net

How to know Page.IsValid on Client Side in Asp.net.

Generally you never run into this scenario, but it is important in case you are doing something which i tried to do.

I was trying to disable Submit button as soon as user press it, in order to avoid multiple button click.

What if error occurred, Validation control on client side will never call server-side function and so our button which was disable, will remain disable. To overcome, this problem, we need to identify whether Page is error free on client-side.

To find Page.IsValid on Client Side, simply check this on Disable Submit Button Javascript 

if (Page_IsValid)
{
}




Example:  Disable Submit Button Javascript Function
function DisableClickUploadArticle() {
var objName = 'btnUploadArticle';
if (Page_IsValid) {
document.getElementById(objName).disabled = true;
a = a + 1;
msg = 'Please Wait...(' + a + ')!';
document.getElementById(objName).value = msg;
var t = setTimeout('DisableClickUploadArticle()', 1000);
}
else {
document.getElementById(objName).disabled = false;
document.getElementById('PleaseWaitUploadArticle').style.display = 'none';
document.getElementById(objName).value = "Submit Article";
}

No comments:

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape