I am using a custom validator and when i post it in the same page it works and fires, however if i post to a different page it does not fire. Here is the code below.
Question2:
Also what is the best place to write the code for redirecting to the next page? in the action="pagename.aspx" or in the postbackurl="" of the button
Code Behind
protected void Custom_Validator_Prepayment(object s, ServerValidateEventArgs args)
{
if ((Session["id"] == null) || (Type.SelectedIndex == 0))
{
args.IsValid = false;
Response.Redirect("default.aspx");
}
else
{
args.IsValid = true;
}
}
protected void button1_Click(object sender, EventArgs e)
{
//Page.Validate();
if (!Page.IsValid)
{
Response.Redirect("../settings/studentmanager/default.aspx");
}
}
Answers
Know the answer? Post it. Somebody with the same question will find it here.