January 2018 : Instructor-led Online Course in ASP.NET Core 2.0. Conducted by Bipin Joshi. Read more...
Registration for January 2018 batch of ASP.NET Core 2.0 instructor-led online course has already started. Conducted by Bipin Joshi. Register today ! Click here for more details.

Developing a feature rich custom TextBox

Objective

For most of the software applications user inputs are accepted via TextBoxes. As per your business requirements inputs differ from Alpha, AlphaNumeric, Integers or Decimals. You may need further fine tuning. Lets say you need only Alpha characters entered in the TextBox. Further there are 3 possibilities. The characters can be All Caps , All Small or InitCap.

Functionality

The control has its own properties as under:

1. For Only Alpha / Alpha Numeric characters

    a. All case
    b. Upper case
    c. Lower case

2. For Numeric characters

    a. Only Numeric
    b. Numeric with decimals

To achieve above functionality I have declared 4 properties

    a. ACCEPTLETTERS - Which have following 4 values

        1.ALL - Accepts alpha / numeric / special characters
        2.ALPHA - Accepts alpha
        3.NUMERIC - Accepts numeric
        4.ALPHANUMERIC - Accepts alphanumeric and decimal if ACCEPTDECIMAL property is set to TRUE

    b. ALLOWDECIMALS - Boolean accepts TRUE / FALSE

    c. ALPHACASE - Which have following 4 values

        1.NONE - Accepts any case
        2.LOWER - Accepts / converts input in lower cases
        3.UPPER - Accepts / converts input in upper cases
        4.INITCAP - Accepts / converts input in First letter Upper

    d. DECIMALLENGTH - Maximum number of decimals allowed when ACCEPTLETTERS property is set to NUMERIC.

The control also takes care of copy and paste done by user. This is achieved by using JavaScript. At runtime JavaScript is registered using "IsClientScriptBlockRegistered" property of the page. Control is not designed to take care for number of decimals entered when input is other than Numeric.

Usage

  • In the �Toolbox� add reference of the control using Add / Remove Items(Right click on toolbox and click �Add Remove Items�).
  • Drag the control as normal TEXTBOX.

The download contains two projects

1. wccTextBox � Web Control Library project for creating Textbox control
2. TextBoxControlDemo � ASP.NET with C# project which is web application. This project is demo for implementation of the control.

Note: The control perfectly works in Internet Explorer 6.0.

 


I am science graduate, Total IT experience 5+ years working with 3i-Infotech Ltd. since last 1.5 years.

Posted On : 30 January 2006


Tags : ASP.NET Web Forms Server Controls Custom Controls