Restrict TextBox to take only numbers.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Restrict TextBox to take only numbers.

  1. #1
    Join Date
    Sep 2008
    Posts
    4

    Question Restrict TextBox to take only numbers.

    Hi,

    This is my dynamic created textbox
    Code:
    Dim Txtdynamic As TextBox = New TextBox
    Txtdynamic.ID = "id1"
    c_placeholder.Controls.Add(Txtdynamic) '
    used in
    Code:
    <asp:PlaceHolder runat="server" ID="c_placeholder"></asp:PlaceHolder>
    My question is how do I restrict this text box to take only numbers.

    I got some hint like
    Code:
    <asp:TextBox ID="TextBox1" runat="server" onkeypress="return increment(event)" ></asp:TextBox>
    but problem is onkeypress event not supported in ASP.Net (in my little knowledge) and I dont use <asp:TextBox> control

    Thanks in Advance

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Welcome to DevX

    See this example. Hopefully it has what you are looking for.

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Sep 2008
    Posts
    4
    Thank You, Its realy help

  5. #5
    Join Date
    Jul 2012
    Posts
    5

    Hi follow this link it is for both for decimal and for integer..


Similar Threads

  1. Create User Wizard
    By saquib189 in forum ASP.NET
    Replies: 1
    Last Post: 09-19-2008, 02:57 PM
  2. add numbers from listbox to a textbox
    By golfmaltais in forum .NET
    Replies: 17
    Last Post: 10-02-2007, 12:43 PM
  3. Add numbers from a list to textbox
    By wesoonline in forum VB Classic
    Replies: 2
    Last Post: 02-21-2007, 10:20 AM
  4. Replies: 1
    Last Post: 07-07-2006, 06:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center