New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Dynamic InputSettings

You extend TextBox controls with RadInputManager by adding InputSettings to RadInputManager. You would generally use the designer to add the markup of your RadInputManager and its InputSettings to your page. Alternatively, you can add InputSettings dynamically from code-behind. To do that, you need to strictly follow these requirements:

  1. Your RadInputManager instance should be dynamically created on Init or Load

  2. You need to initialize and add the InputSettings to the RadInputManager first.

  3. You need to add RadInputManager to the Page after you have added all the InputSettings.

protected void Page_Init(object sender, EventArgs e)
{
    RadInputManager inputManager = new RadInputManager();
    inputManager.ID = "RadInputManager1";
    NumericTextBoxSetting numericSetting = new NumericTextBoxSetting();

    numericSetting.Validation.IsRequired = true;
    numericSetting.TargetControls.Add(new TargetInput(TextBox1.ID, true));

    inputManager.InputSettings.Add(numericSetting);
    Page.Form.Controls.Add(inputManager);
}
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    Dim inputManager As New RadInputManager()
    inputManager.ID = "RadInputManager1"

    Dim numericSetting As New NumericTextBoxSetting()
    numericSetting.Validation.IsRequired = True
    numericSetting.TargetControls.Add(New TargetInput(T1.ID, True))

    inputManager.InputSettings.Add(numericSetting)
    Page.Form.Controls.Add(inputManager)
End Sub

You can add InputSettings both for static and dynamic TextBox controls in this way. What is important is that RadInputManager contains all the settings by the time it is added to the Page. Otherwise, RadInputManager's built-in validation will not work.

In this article