The following example demonstrates some of the main properties and functionalities of the RadNumericTextBox control. The code shows how to dynamically set the visibility of the spin buttons, keyboard and mouse wheel incrementation of the numeric textbox value.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.InputExamplesCS.Examples.RadNumericTextBox.FirstLook.DefaultCS" %><%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %><%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %><%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %><%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag></head><body class="BODY"> <form runat="server" id="mainForm" method="post"> <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#"></qsf:Header> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <!-- content start --> <div> <telerik:RadAjaxPanel runat="server" ID="AjaxPanel1"> <telerik:RadNumericTextBox ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true" IncrementSettings-InterceptMouseWheel="true" Label="RadNumericTextBox" runat="server" ID="Numeric1" Width="200px"> </telerik:RadNumericTextBox> <qsf:ConfiguratorPanel Title="General Settings" ID="ConfiguratorPanel" runat="server" Expanded="true"> <table> <tr> <td> Empty message: </td> <td> <asp:TextBox runat="server" ID="EmptyMessage" AutoPostBack="true" Text="Set empty message" OnTextChanged="EmptyMessage_TextChanged"> </asp:TextBox> </td> </tr> <tr> <td> Show SpinButtons: </td> <td> <asp:CheckBox runat="server" ID="ShowSpinButtons" Checked="true" AutoPostBack="true" OnCheckedChanged="ShowSpinButtons_CheckedChanged" /> </td> </tr> <tr> <td> Show Label: </td> <td> <asp:CheckBox runat="server" ID="ShowLabel" Checked="true" AutoPostBack="true" OnCheckedChanged="ShowLabel_CheckedChanged" /> </td> </tr> <tr> <td> Keyboard increment: </td> <td> <asp:CheckBox runat="server" ID="KeyboardIncrement" Checked="true" AutoPostBack="true" OnCheckedChanged="KeyboardIncrement_CheckedChanged" /> </td> </tr> <tr> <td> Mouse wheel increment: </td> <td> <asp:CheckBox runat="server" ID="MouseWheel" Checked="true" AutoPostBack="true" OnCheckedChanged="MouseWheel_CheckedChanged" /> </td> </tr> </table> </qsf:ConfiguratorPanel> <telerik:RadNumericTextBox ShowSpinButtons="True" Type="Currency" Width="200px" ID="RadNumericTextBox1" runat="server" Culture="Bulgarian (Bulgaria)" InvalidStyleDuration="100"> <NumberFormat AllowRounding="True" KeepNotRoundedValue="False" /> </telerik:RadNumericTextBox> <qsf:ConfiguratorPanel Title="Globalization Settings" ID="ConfiguratorPanel2" runat="server" Expanded="true"> <table> <tr> <td> SpecificCultures: </td> <td> <asp:DropDownList OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true" ID="DropDownList1" runat="server" Width="205"> <asp:ListItem Value="en-US" Selected="True">English (United States)</asp:ListItem> <asp:ListItem Value="de-DE">German (Germany)</asp:ListItem> <asp:ListItem Value="bg-BG">Bulgarian (Bulgaria)</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> Type: </td> <td> <asp:DropDownList OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" AutoPostBack="true" ID="DropDownList2" runat="server" Width="205"> <asp:ListItem Text="Number" Value="Number"></asp:ListItem> <asp:ListItem Selected="True" Text="Currency" Value="Currency"></asp:ListItem> <asp:ListItem Text="Percent" Value="Percent"></asp:ListItem> </asp:DropDownList> </td> </tr> </table> </qsf:ConfiguratorPanel> <telerik:RadNumericTextBox ShowSpinButtons="True" Value="2555666.65" Type="Currency" ID="RadNumericTextBox3" runat="server" Culture="Bulgarian (Bulgaria)" InvalidStyleDuration="100" LabelCssClass="radLabelCss_Outlook" Width="125px"> <NumberFormat AllowRounding="True" KeepNotRoundedValue="False" /> </telerik:RadNumericTextBox> <qsf:ConfiguratorPanel Title="Numeric Settings" ID="ConfiguratorPanel1" runat="server" Expanded="true"> <table> <tr> <td> </td> <td> DecimalDigits: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList31" runat="server"> <asp:ListItem Value="0">0</asp:ListItem> <asp:ListItem Selected="True" Text="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> <asp:ListItem Value="5">5</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> </td> <td> DecimalSeparator: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList32" runat="server"> <asp:ListItem Selected="True" Value=".">.</asp:ListItem> <asp:ListItem Value=",">,</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> </td> <td> GroupSeparator: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList33" runat="server"> <asp:ListItem Selected="True" Value=" ">' '</asp:ListItem> <asp:ListItem Value=",">,</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> </td> <td> GroupSizes: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList34" runat="server"> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Selected="True" Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> </td> <td> NegativePattern: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList35" runat="server"> <asp:ListItem Selected="True" Value="$ -n">$ -n</asp:ListItem> <asp:ListItem Value="BGN -n">BGN -n</asp:ListItem> <asp:ListItem Value="-n JPY">-n JPY</asp:ListItem> <asp:ListItem Value="-n km">-n km</asp:ListItem> <asp:ListItem Value="n- kg">n- kg</asp:ListItem> <asp:ListItem Value="-n %">-n %</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td> </td> <td> PositivePattern: </td> <td> <asp:DropDownList OnSelectedIndexChanged="SelectedIndexChanged" Width="100px" AutoPostBack="true" ID="DropDownList36" runat="server"> <asp:ListItem Selected="True" Value="$ n">$ n</asp:ListItem> <asp:ListItem Value="BGN n">BGN n</asp:ListItem> <asp:ListItem Value="n JPY">n JPY</asp:ListItem> <asp:ListItem Value="n km">n km</asp:ListItem> <asp:ListItem Value="n kg">n kg</asp:ListItem> <asp:ListItem Value="n %">n %</asp:ListItem> </asp:DropDownList> </td> </tr> </table> </qsf:ConfiguratorPanel> </telerik:RadAjaxPanel> </div> <!-- content end --> <qsf:Footer runat="server" ID="Footer1"></qsf:Footer> </form></body></html>
Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.
Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.
If you have any questions, do not hesitate to contact us at sales@telerik.com.