This is a migrated thread and some comments may be shown as answers.

TabStrip Validation

9 Answers 218 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Bobby
Top achievements
Rank 1
Bobby asked on 22 Oct 2008, 03:44 PM
Hello,

I have a tab strip of five tabs, each has a user control dynamically loaded into a corresponding multi page.  Each of the user control's has it's own validation, and when I click a button that causes validation, I only want it to validate that particular user control, with javascript.  Everything is set up properly as far as the validation controls, but every tab validates when I only want the currently selected tab to validate.  Can anyone help me on this?

9 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 04 Nov 2008, 10:35 PM
Try setting
CausesValidation="false" 
on the tabstrip and see if that helps.
0
Bobby
Top achievements
Rank 1
answered on 04 Nov 2008, 10:43 PM
Hello Greg,

Unfortunately, this is already been done.  In order to get the tab strip to work the way we'd like it to, we'd have to continuously update the ValidationGroup setting on the TabStrip each time a different tab were clicked. 

Since there is no validation settings on the MultiPage control, it is all done at the TabStrip level...

Thanks for your help though...

0
Accepted
Chris
Top achievements
Rank 1
answered on 06 Nov 2008, 03:14 PM
The only other thing that I can think of is to set the RenderSelectedPageOnly to true on the multipage control in addition to my previous suggestion.
0
Bobby
Top achievements
Rank 1
answered on 06 Nov 2008, 04:08 PM
That is pretty much the solution that we came up with as well...We were trying to be a little more slick with the lazy loading of user controls and their validation, but doesn't appear that's going to be effective.

Thanks for the input though Greg, it's appreciated.
0
Rory
Top achievements
Rank 1
answered on 15 Mar 2010, 07:43 PM
Hi Telerik et al,
What if we want our "unrendered validators" to fire?

We are using tabstrip as a multi tab form and we are leveraging RenderSelectedPageOnly="True" to increase performance on page load and save times. The issue is if any field has a requiredfieldvalidator on another tab and you click save without visiting that tab the validation doesn't fire. We thought that at least the server side validation would fire since we can see the controls server side on save. Any help would be appreciated.
Thanks.
0
Craig Wallace
Top achievements
Rank 1
answered on 30 Jun 2011, 11:27 AM
Hi Rory,

I am experiencing the same issue with Version 2010.3.1215.40 of the controls.  Did you ever get this resolved?  Can someone from Telerik comment on whether this is still an issue?

Thanks,

Craig
0
Rory
Top achievements
Rank 1
answered on 30 Jun 2011, 05:45 PM
Hey Craig,
Telerik basically can't fix this issue because it is a .net bug.

I had to build a custom method that fires during the server side Save(). It iterates thru all
of the validators and evaluates them manually. If any of the validator's are invalid
we respond with an alert that lists which are invalid and then select the tab and multipage
based on the validation group. I've pasted some of the code below.
Let me know if you'd like to see more or have questions.
Good Luck.


protected
bool CustomPageValidation()
{
bool customPageIsValid = Page.IsValid;
              
try
{
if (Page.IsValid)//If the current tab you are on IsValid
{
    //Reset Custom Validation Group to Empty String
    cvCustomPageValidation.ErrorMessage = "Validation Errors:";
    cvCustomPageValidation.Text = cvCustomPageValidation.ErrorMessage;
    cvCustomPageValidation.ValidationGroup = "";
  
    //Fire All Required Field Validators
    for (int i = 0; i < Page.Validators.Count; i++)
    {
        BaseValidator val = (BaseValidator)Page.Validators[i];
        if (val.GetType().Name == "RequiredFieldValidator" || val.GetType().Name == "RegularExpressionValidator")
        {
            ValidateControl(val);
        }
        else if (val.GetType().Name == "CustomValidator")
        {
            CustomValidator cVal = (CustomValidator)Page.Validators[i];
            if (cVal.ClientValidationFunction == "ComboBoxCustomRequiredFieldValidator")
            {
                if (cVal.ID != "cvDelayedReason" && cVal.ID != "cvDeniedReason" && cVal.ID != "cvReopenedReason")
                {
                    ValidateControlCustomCBO(cVal);
                }
                else
                {
                    //Use Custom Logic for these CV's
                    if (cVal.ID == "cvDelayedReason" && chkDelayed.Checked == true)
                        ValidateControlCustomCBO(cVal);
                    else if (cVal.ID == "cvDeniedReason" && chkDenied.Checked == true)
                        ValidateControlCustomCBO(cVal);
                    else if (cVal.ID == "cvReopenedReason" && cboClaimStatus.SelectedItem != null && cboClaimStatus.SelectedValue == "2") //Re-Open
                        ValidateControlCustomCBO(cVal);
                }
            }
        }
    }
  
}
  
if (cvCustomPageValidation.ValidationGroup.Length > 0)
{
    customPageIsValid = false;
    claimTabs.SelectedIndex = Convert.ToInt32(cvCustomPageValidation.ValidationGroup);
    rmpClaim.SelectedIndex = claimTabs.SelectedIndex;
}
}
catch (Exception ex)
{
    SimsException.ProcessException(ex2, ref lblMessages);
    customPageIsValid = false;
}
  
return customPageIsValid;
}
  


private void ValidateControl(BaseValidator val)
{
    Control ctl = val.FindControl(val.ControlToValidate);
    if (!SIMSUtilities.ControlIsValid(ctl, val))
        UpdateCustomPageValidator(val.ErrorMessage, val.ValidationGroup);
}
0
Craig Wallace
Top achievements
Rank 1
answered on 01 Jul 2011, 09:37 AM
Hi Rory,

Thanks for responding.  I'm not sure how, but it seems to work ok in the current vesion of the Telerik controls (2011.1.519.40).

Craig
0
Rory
Top achievements
Rank 1
answered on 01 Jul 2011, 04:29 PM
Good news Craig.
We're still on a late 2010 release so I'll have to check and see if it is working for me later on when we schedule another upgrade. The ironic part is the original poster Bobby was using this bug as a work around so I am interested to see if their app is no longer working as desired in the 2011 release.
Tags
TabStrip
Asked by
Bobby
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Bobby
Top achievements
Rank 1
Rory
Top achievements
Rank 1
Craig Wallace
Top achievements
Rank 1
Share this question
or