If you validate page. validators which are present in active view will only be validated.
if you want to validate customvalidator which is present in "anothor view" (Not activew view), then before validating you need to set activeview index as that "anothor view" and then validate page.
if page is valid then redirect it to another page else do nothing.
To prevent next or previous page when page.isvalid = false you can use IPostBackEventHandler concept.
Anyone know how to prevent next or previous page when page.isvalid = false?
Assume that
previouspage
andnext
pageare
controlledby a Button(Orsimilar
controls ) control. You
cancheck the page.isvalid value to decide
thecontrol is
enabledor
disabled:
if(!page.isvalid)
{
nextButton.Enabled =false;}
Please mark the replies as answers if they help or unmark if not.
Feedback to us
you can do it in javascript too...you can check for Page_ClientValidate(), it returns flase if validations fail....use that same like "return Page_ClientValidate()" in onclientclick for a button...
cooper88
Member
116 Points
103 Posts
CustomValidator issues with MultiView-control
May 09, 2012 06:44 AM|LINK
Anyone know how to prevent next or previous page when page.isvalid = false?
Thulasiram
Member
438 Points
93 Posts
Re: CustomValidator issues with MultiView-control
May 09, 2012 02:08 PM|LINK
If you validate page. validators which are present in active view will only be validated.
if you want to validate customvalidator which is present in "anothor view" (Not activew view), then before validating you need to set activeview index as that "anothor view" and then validate page.
if page is valid then redirect it to another page else do nothing.
To prevent next or previous page when page.isvalid = false you can use IPostBackEventHandler concept.
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: CustomValidator issues with MultiView-control
May 15, 2012 10:17 AM|LINK
Assume that previous page and next page are controlled by a Button(Or similar controls ) control. You can check the page.isvalid value to decide the control is enabled or disabled:
if(!page.isvalid)
{ nextButton.Enabled =false;}
Feedback to us
Develop and promote your apps in Windows Store
ramiramilu
All-Star
95463 Points
14106 Posts
Re: CustomValidator issues with MultiView-control
May 15, 2012 11:19 AM|LINK
you can do it in javascript too...you can check for Page_ClientValidate(), it returns flase if validations fail....use that same like "return Page_ClientValidate()" in onclientclick for a button...
Thanks.,
JumpStart
w_nairb
Member
114 Points
37 Posts
Re: CustomValidator issues with MultiView-control
May 15, 2012 11:47 AM|LINK
Try stepping through the Views using the following example.
protected void MoveNext_Click(object sender, System.EventArgs e) { if (mvForm.ActiveViewIndex > -1 & mvForm.ActiveViewIndex < 2) { if (Page.IsValid) { // Validate fields switch (mvForm.GetActiveView().ID.ToString()) { case "vStep1": if (tbFirstName.Text.Trim().Length == 0 || tbLastName.Text.Trim().Length == 0) { // Handle error } else { // Move to next step mvForm.ActiveViewIndex += 1; } break; case "vStep2": if (tbStreet.Text.Trim().Length == 0 || tbCity.Text.Trim().Length == 0 || tbZipCode.Text.Trim().Length == 0) { // Handle error } else { // Move to next step mvForm.ActiveViewIndex += 1; } break; case "vStep3": if (tbComments.Text.Trim().Length == 0) { // Handle error } else { // Move to next step mvForm.ActiveViewIndex += 1; } break; } } } else { // Handle error } }