ASP.Net Server control that allows only numbers. Basic formatting for US currency and comma separation are provided

LZDollarTextbox is an ASP.Net server control that makes handling numeric only data easier for web applications. It is developed in VB.Net (easy to convert to C#) and Javascript.

This control was developed due to an odd lack of anything in the open source domain that really fulfilled the requirement for a simple numeric only textbox that handles basic US numeric/currency formatting. There are plenty of tutorials that demo how to almost get the complete functionality, but nothing that's just simple to include in your project and register on a form.

The code is pretty straightforward and javascript. The javascript is registered as a resource in the compiled assembly and inserted into your target page upon execution, so no additional files are necessary for distribution.

-Rick Little

The control is based on the standard textbox control so it works with databinding as you'd expect. A sample Visual Studio 2008 Solution with a web application is included for testing.

Basic Usage
  1. Include Assembly with your project
  2. Register tag for your page ex. <%@ Register Assembly="NumericTextBox" Namespace="LZDollarTextBox" TagPrefix="cc1" %>
  3. Setup control ex. <cc1:NumericTextBox ID="DIO" ControlWidth="120" runat="server" AllowDecimal="True" Text="1232.2123122" DecimalPlaces="4" CanWrite="True" DollarSign="False" />

Last edited Jul 21, 2009 at 4:46 AM by h3yrick, version 4