How can I set the ASP.NET validators to be visible by default?

To make the validators on a page visible by default you can call the
page’s Validate() method when it is loading, as in:


private void Page_Load(object sender, System.EventArgs e)
{

   if (!IsPostBack)
{
Page.Validate();
}
}

Or if you want to make visible only one validator, use:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
   // Where reqEmail is the validator
reqEmail.Validate();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top