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

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

1 Answer 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michiel Peeters
Top achievements
Rank 1
Michiel Peeters asked on 20 Sep 2010, 02:41 PM
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);
    this.dynamicFieldControlSequenceIds.Add(controlId);
 
    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);
    textualValidationSetting.TargetControls.Add(textualValidationInput);
 
    inputManager.InputSettings.Add(textualValidationSetting);
 
    this.dynamicControls.Add(textualTextbox);
 
    return textualTextbox;
}

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

Kind regards,
Michiel Peeters

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Sep 2010, 01:11 PM
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,
Martin
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
Tags
General Discussions
Asked by
Michiel Peeters
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or