Monday, August 20, 2012

Java script validation on Server side in asp.net

Title:Java script validation in asp.net

Description :
As per previous articles,we discussed on java script validation on client side in asp.net .Now i would like give an example on validation which can be done on server side.In the below example i have used a web server control (Text box size) which should contain 30 characters with specified text format
Example:

if (TxtFormate.Text == "")
{
ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Enter Format');</script>");
TxtFormate.Focus();
return;
}
if (int.Parse(TxtFormate.Text.Length.ToString()) > 30)
{
ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Allows only 0 to 30 Characters');</script>");
TxtFormate.Focus();
return;
}

No comments:

Bel