Categories validation

How does Page.IsValid work?

I have following code with a RequiredFieldValidator. The EnableClientScript property is set as “false” in the validation control. Also I have disabled script in browser.

I am NOT using Page.IsValid in the code behind. Still, when I submit without any value in textbox I will get error message.

From comments of @Dai, I came to know that this can be an issue, if there is any code in Page_Load that is executed in a postback. There will be no validation errors thrown.

(However, for button click handler, there is no need to check Page.IsValid)

if (Page.IsPostBack)
string value = txtEmpName.Text;
txtEmpName.Text = value + "Appended";


  1. Why does not the server side validation happen before Page_Load?
  2. Why does it work fine when I use Page.IsValid?
  3. Can you provide any reference to an article that explains this? (Not something that says – always use Page.IsValid; but something that says what are the mandatory scenarios to use Page.IsValid


Refer ASP.NET Validators Common Misconception

Page.IsValid is accessible only after running Page.Validate() method which is invoked implicitly somewhere after Page_Load. In case you keep all of your logic in a Page_Load event handler (which is highly discouraged!), call the Page.Validate() before checking the Page.IsValid.

Note: It is advised not to keep all the logic in Page_Load. If something is to happen on button click event, move it to button click event handler. If something is to happen on drop-down event, move it to drop-down selected item change event handler.


It seems like, we need to add If(Page.IsValid) in button click also if we are using a Custom Validator with server side validation. Refer CustomValidator not working well.

Note: Client side validation question is present here: Whether to use Page_IsValid or Page_ClientValidate() (for Client Side Events)


<html xmlns="">
<head runat="server">
<script type="text/javascript">
<form id="form1" runat="server">
<asp:ValidationSummary runat="server" ID="vsumAll" DisplayMode="BulletList" CssClass="validationsummary" ValidationGroup="ButtonClick" />
<asp:TextBox ID="txtEmpName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="valEmpName" runat="server" ControlToValidate="txtEmpName"
EnableClientScript="false" ErrorMessage="RequiredFieldValidator" Text="*" Display="Dynamic"
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" ValidationGroup="ButtonClick" />


protected void Button1_Click(object sender, EventArgs e)
string value = txtEmpName.Text;


  1. Should I always call Page.IsValid?
  2. ASP.NET Validation Controls – Important Points, Tips and Tricks
  3. CustomValidator not working well