RadControls for ASP.NET AJAX
Broadly speaking, there are two groups of controls which are extended using the RadInputManager. The first are controls which are located directly on the page, such as a normal text box somewhere on the form. The second are text boxes located in another control- for example a text box nested in a repeater.
Additionally, within the RadInputManager, there are four types of settings which could be added:
- telerik:DateInputSetting – the targeted text box will be accepting input in a date format
- telerik:NumericTextBoxSetting – the targeted textbox will be accepting numeric input
- telerik:RegExpTextBoxSetting – the targeted text box will be accepting characters corresponding to a specified regular expression
- telerik:TextBoxSetting – the targeted text box will exhibit behavior like a normal RadTextBox
Each one of these setting groups allows for different behavior. Let us assume that we have two standard textboxes on the form, and we wanted one of them to exhibit behavior similar to a RadTextBox, and the other one as a RadNumericTextBox. In this case, the declaration of the two textboxes, along with the RadInputManager, would look like this:
CopySample code
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<telerik:RadInputManager ID="RadInputManager1" runat="server">
<telerik:TextBoxSetting BehaviorID="Setting1" EmptyMessage="EmptyMessage55">
<TargetControls>
<telerik:TargetInput ControlID="TextBox1" />
</TargetControls>
</telerik:TextBoxSetting>
<telerik:NumericTextBoxSetting Type="Currency" BehaviorID="Setting2">
<TargetControls>
<telerik:TargetInput ControlID="TextBox2" Enabled="true" />
</TargetControls>
</telerik:NumericTextBoxSetting>
</telerik:RadInputManager>Each of the Setting tags contains a BehaviorID, which is used to identity settings pertaining to a given text box. These can later be retrieved on the client, for example, and access a property such as the EmptyMessage.
Caution |
|---|
Note that each input setting must have at least one target control, otherwise it will not be serialized to the client and its client object would not be instantiated. |
Additionally, we can extend text boxes located in other controls. For example, let us assume that we have a repeater hosting a text box. Further, if we want the text box(es) nested in the repeater to accept only e-mail addresses (a regular expression is used to determine this behavior), the setup would look something like:
CopySample code
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<br />
Internet e-mail address:
<asp:TextBox ID="TextBox1" Text="mailto:e-mail@goes.here" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
<telerik:RadInputManager ID="RadInputManager1" runat="server">
<telerik:RegExpTextBoxSetting EmptyMessage="EmptyMessage" BehaviorID="Setting3" ValidationExpression="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"
ErrorMessage="ErrorMessage">
<TargetControls>
<telerik:TargetInput ControlID="Repeater1" />
</TargetControls>
</telerik:RegExpTextBoxSetting>
</telerik:RadInputManager>Below is a list of four tables, covering the most important properties of the elements discussed up to now:
TextBoxSettings
BehaviorID | A unique id for the settings related to a given textbox. |
ClientEvents-OnBlur | The name of the client side handler which will be raised when the control loses focus. |
ClientEvents-OnError | The name of the client side function which will be called when an error occurs – the user enters invalid input. This event is not raised for the textbox control, since there is no input restriction. |
ClientEvents-OnFocus | The name of the client side function which will be called when the control receives focus. |
ClientEvents-OnKeyPress | The name of the client side function which will be called when the user presses a button, while the control has the focus. |
EmptyMessage | The text which will be displayed before the user has entered any text. |
EmptyMessageCssClass | The name of the css class which will be used to style the empty message text. |
InvalidCssClass | The name of the css class, which will be used to style the control, when the user enters invalid input |
| DisabledCssClass | The name of the css class which will be used to style the control when it is disabled. |
SelectionOnFocus | An enumeration which is used to determine how the input control behaves when it first gets input focus. The possible values are CaretToBeginning, CaretToEnd, None and SelectAll. The default one is CaretToEnd. |
InitializeOnClient | A property which indicates whether the client event handlers and css classes will be set on the client. |
PasswordStrengthSettings | A group of properties used for setting up the password strength check feature when using a TextBox with TextMode set to Password. More information is available
here. |
RegExpTextBoxSetting
BehaviorID | A unique id for the settings related to a given textbox. |
ClientEvents-OnBlur | The name of the client side handler which will be raised when the control loses focus |
ClientEvents-OnError | The name of the client side function which will be called when an error occurs – the user enters invalid input |
ClientEvents-OnFocus | The name of the client side function which will be called when the control receives focus |
ClientEvents-OnKeyPress | The name of the client side function which will be called when the user presses a button, while the control has the focus |
EmptyMessage | The text which will be displayed before the user has entered any text |
ErrorMessage | A message which is displayed if the regular expression matching fails |
InvalidCssClass | The name of the css class, which will be used to style the control, when the user enters invalid input |
InitializeOnClient | A property which indicates whether the client event handlers and css classes will be set on the client |
IsRequiredFields | A property which indicates whether the corresponding textboxes are required to have some values entered, or may be empty |
SelectionOnFocus | An enumeration which is used to determine how the input control behaves when it first gets input focus. The possible values are CaretToBeginning, CaretToEnd, None and SelectAll. The default one is CaretToEnd. |
ValidationExpression | A regular expression, representing the matching criteria. |
| ValidationGroup | The ValidationGroup to which the regular expression setting is assigned. |
NumericTextBoxSetting
BehaviorID | A unique id for the settings related to a given textbox. |
ClientEvents-OnBlur | The name of the client side handler which will be raised when the control loses focus |
ClientEvents-OnError | The name of the client side function which will be called when an error occurs – the user enters invalid input |
ClientEvents-OnFocus | The name of the client side function which will be called when the control receives focus |
ClientEvents-OnKeyPress | The name of the client side function which will be called when the user presses a button, while the control has the focus |
EmptyMessage | The text which will be displayed before the user has entered any text |
EmptyMessageCssClass | The name of the css class which will be used to style the empty message text |
KeepTrailingZerosOnFocus | A property which determines if the zero numbers should remain when the control is focused, according to the DecimalDigits setting |
MaxValue | The maximal numeric value which can be entered in the control |
NumberFormat-AllowRounding | A setting which specifies whether the user input may be rounded |
SelectionOnFocus | An enumeration which is used to determine how the input control behaves when it first gets input focus. The possible values are CaretToBeginning, CaretToEnd, None and SelectAll. The default one is CaretToEnd. |
Type | The type of the control – Currency/Number/Percent |
MinValue | The minimal numeric value which can be entered in the control |
DateInputSetting
BehaviorID | A unique id for the settings related to a given textbox. |
ClientEvents-OnBlur | The name of the client side handler which will be raised when the control loses focus |
ClientEvents-OnError | The name of the client side function which will be called when an error occurs – the user enters invalid input |
ClientEvents-OnFocus | The name of the client side function which will be called when the control receives focus |
ClientEvents-OnKeyPress | The name of the client side function which will be called when the user presses a button, while the control has the focus |
DateFormat | The date format string for the control |
EmptyMessage | The text which will be displayed before the user has entered any text |
EmptyMessageCssClass | The name of the css class which will be used to style the empty message text |
MaxDate | The maximal date which the user will be allowed to enter |
MinDate | The minimal date which the user will be allowed to enter |
SelectionOnFocus | An enumeration which is used to determine how the input control behaves when it first gets input focus. The possible values are CaretToBeginning, CaretToEnd, None and SelectAll. The default one is CaretToEnd. |