Wednesday, July 7, 2010

Formatting textbox : RadNumericTextBox

If we need to format a textbox, so that we don't need to validate the input and if you can use telerik controls. You should use RadNumericTextBox control.


Before you need something like this in order to validate a number with maximum 4 decimals.


1 <asp:TextBox ID="txtTaxRate" runat="server" CssClass="textbox_num_enabled2" Width="50px" MaxLength="7" text='<%#DataBinder.Eval(Container, "DataItem.TaxRate") %>'></asp:TextBox>
2 <asp:RegularExpressionValidator ID="revTaxRate" runat="server"

3 ErrorMessage="RegularExpressionValidator" CssClass="error2"

4 ControlToValidate="txtTaxRate" ValidationExpression="^\d{0,2}(\.\d{1,4})?$"></asp:RegularExpressionValidator>

5

6

Now, you just need a RadNumeric Textbox like this:

1 <telerik:RadNumericTextBox ID="txtTaxRate" runat="server" DataType="System.Int64" MaxLength="9"
2 MaxValue="99.9999" MinValue="0" Skin="" CssClass="textbox_num_enabled2" EnableEmbeddedSkins="False"

3 Width="80px" text='<%#DataBinder.Eval(Container, "DataItem.TaxRate") %>
'>
4 <NumberFormat DecimalDigits="4" />

5 </telerik:RadNumericTextBox>

6

7

No comments:

Post a Comment