[RadInputManager/RegExpTextboxSetting] After validation my controls are all the time cleared

2 posts, 0 answers
  1. Michiel Peeters
    Michiel Peeters avatar
    46 posts
    Member since:
    Apr 2010

    Posted 20 Sep 2010 Link to this post

    Dear Telerik Community,

    Currently i am developing an dynamic field initializer where validation expressions are used. Those expressions are set dynamicly in de codebehind attached to a textbox for example. My problem lays in the option that i sometimes don't want to set the validation expression in the regexptextboxsetting for example. When i leave the validationexpression empty the textbox will validate but on the wrong way. It automaticly deletes the value of the textbox and gives an warning sign that it is not correct.

    My question is, can i set the validationexpression empty so that no validation is set and that it wont validate the control? In the following code snippit you will see what i have done:

    /// <summary>
    /// Generates the textual control.
    /// </summary>
    /// <param name="fieldDefinition">Fielddefinition that holds the data that needs to be set on the control.</param>
    /// <returns>A textual control based on a textbox.</returns>
    private TextBox textualControl(ServiceObjectFieldDefinition fieldDefinition, RadInputManager inputManager)
        string controlId = string.Format("dynamicFieldControl-{0}", fieldDefinition.Id);
        RegExpTextBoxSetting textualValidationSetting = new RegExpTextBoxSetting();
        textualValidationSetting.BehaviorID = controlId;
        TextBox textualTextbox = new TextBox();
        textualTextbox.ID = controlId;
        if (fieldDefinition.Mandatory)
            textualValidationSetting.Validation.IsRequired = true;
        if (fieldDefinition.MaxLength != null)
            textualTextbox.MaxLength = Convert.ToInt32(fieldDefinition.MaxLength);
        if (!string.IsNullOrEmpty(fieldDefinition.DefaultValue))
            textualTextbox.Text = fieldDefinition.DefaultValue;
        if (fieldDefinition.DefaultValueFixed)
            textualTextbox.Enabled = false;
        textualValidationSetting.ValidationExpression = fieldDefinition.MinLength != null ? string.Format("{{0},}", Convert.ToInt32(fieldDefinition.MinLength)) : "{0,}";
        TargetInput textualValidationInput = new TargetInput(controlId, true);
        return textualTextbox;

    Maybe my thougts are wrong :-) so can somebody help me?

    Kind regards,
    Michiel Peeters
  2. Martin
    Martin avatar
    810 posts

    Posted 23 Sep 2010 Link to this post

    Hello Michiel Peeters,

    Indeed you are correct that RegExpTextBoxSetting validation should pass when ValidationExpression is not set, Validation-IsRequired="true" and some text is entered into the text box. The issue is already fixed and will be available in the next Latest Internal Build which is scheduled for the next week.

    If you would like your validation to pass even when the text box is left empty, then just set Validation-IsRequired="false" for the relevant RegExpTextBoxSetting.

    I hope this helps.

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top