I know this is old, but I needed to do something similar, basically forcing the IsValid property by mistake (don't ask why). Here is what I basically did (what you see here is my proof of concept):
Added this to the .aspx page:
<asp:TextBox ID="txtDummy" runat="server" Visible="false" /> <asp:RangeValidator ID="rvDummy" ControlToValidate="txtDummy" runat="server" MinimumValue="1" MaximumValue="2" />
And then I added this to the code behind:
bool makeMyPageInvalid = true; if (makeMyPageInvalid) txtDummy.Text = "0"; Page.Validate(); if (Page.IsValid) ScriptManager.RegisterStartupScript(Page, Page.GetType(), "test", "alert('valid');", true); else ScriptManager.RegisterStartupScript(Page, Page.GetType(), "test", "alert('not valid');", true);
You can see that this only allows you to force a page to check for an invalid state. You can use any validator or reason to establish this. Hope this helps someone!
source share