TabStrip Validation

10 posts, 1 answers
  1. Bobby
    Bobby avatar
    4 posts
    Member since:
    Oct 2008

    Posted 22 Oct 2008 Link to this post

    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?
  2. Chris
    Chris avatar
    20 posts
    Member since:
    Sep 2007

    Posted 04 Nov 2008 Link to this post

    Try setting
    CausesValidation="false" 
    on the tabstrip and see if that helps.
  3. Bobby
    Bobby avatar
    4 posts
    Member since:
    Oct 2008

    Posted 04 Nov 2008 Link to this post

    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...

  4. Answer
    Chris
    Chris avatar
    20 posts
    Member since:
    Sep 2007

    Posted 06 Nov 2008 Link to this post

    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.
  5. Bobby
    Bobby avatar
    4 posts
    Member since:
    Oct 2008

    Posted 06 Nov 2008 Link to this post

    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.
  6. Rory
    Rory avatar
    159 posts
    Member since:
    Jul 2007

    Posted 15 Mar 2010 Link to this post

    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.
  7. Craig Wallace
    Craig Wallace avatar
    118 posts
    Member since:
    Jan 2005

    Posted 30 Jun 2011 Link to this post

    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
  8. Rory
    Rory avatar
    159 posts
    Member since:
    Jul 2007

    Posted 30 Jun 2011 Link to this post

    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);
    }
  9. Craig Wallace
    Craig Wallace avatar
    118 posts
    Member since:
    Jan 2005

    Posted 01 Jul 2011 Link to this post

    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
  10. Rory
    Rory avatar
    159 posts
    Member since:
    Jul 2007

    Posted 01 Jul 2011 Link to this post

    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.
Back to Top