Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1071375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:42:26+00:00 2026-05-16T20:42:26+00:00

Hai Freinds So far i have used this coding to create a custom Control

  • 0

Hai Freinds

So far i have used this coding to create a custom Control as my knowledge in the pervious post.i dono it is correct or not.I need a further help regarding this.so far i have used this coding the appcode->Number.cs in that i have used this coding further what should i do: my requriements is that i drag the textbox in the controls only number should be entered in that. for reference see my previous post:http://www.eggheadcafe.com/community/aspnet/2/10200401/how-to-create-a-dll-file-for-the-textbox-with-some-requriments.aspx.i need it in web applications

using System;  
using System.Data;  
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;    
using System.Web.UI;    
using System.Web.UI.HtmlControls;    
using System.Web.UI.WebControls;    
using System.Web.UI.WebControls.WebParts;    
using System.Xml.Linq;

/// <summary>     
/// Summary description for Number    
/// </summary> 
public class Number : TextBox    
{    
    protected override void OnKeyPress(KeyPressEventArgs e)     
    {    
        base.OnKeyPress(e);     
        if (e.KeyChar >= '0' && e.KeyChar <= '9')     
        {    
            e.Handled = false;        
        }   
        else 
        {    
            e.Handled = true;     
        }  
    }   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:42:26+00:00Added an answer on May 16, 2026 at 8:42 pm

    We have created the same type of control for our need. We used js file for that.
    The following function only allows numbers.

    Please use this link to create a custom control http://www.codeproject.com/KB/custom-controls/CreateNumTextBoxControl.aspx

       function CheckOnlyInteger(e, sender, allowNegative) {
        e = e || window.event;
        //var key = (window.event) ? e.keyCode : e.which;
        var key = e ? e.keyCode : e.which;
        //alert(key);
        if (e.shiftKey) {
            if ((key > 47 && key < 58) || (key == 192) || (key >= 37 && key <= 39) || key == 0)     {
            return false;
          }
       }
       if ((key >= 48 && key <= 57) || // 0-9 numbers
        (key >= 35 && key <= 40) || // Left, Up, Right and Down
        key == 8 || // backspaceASKII
        key == 9 || // tabASKII
        key == 16 || // shift
        key == 17 || // control
        (key >= 96 && key <= 105) || (key == 46)) // || // Home  key == 46) // dotASKII
    {
        return true;
    }
     else if ((key == 45) && (allowNegative == 'true')) { // dash (-)       
        if (sender.value.indexOf('-') > -1) {
            return false;
        }
         else {
            if (sender.value.indexOf('-') == 0) {
                return true;
             }
             else {
                sender.value = sender.value.replace('-', '');
                sender.value = "-" + sender.value;
                return true;
             } //alert(key + ' ' + sender.value + ' ' + allowNegative);    alert((key == 45) && (allowNegative == true));
        }
    }
    else
        return false;
     }
    
    
      public partial class ANTextBox: System.Web.UI.WebControls.TextBox 
        {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
    
            ClientScriptManager scriptMananger = this.Page.ClientScript;
            string resourceFilePath = "TBControlLibrary.Resources.AlphaNumeric.js";
    
            scriptMananger.RegisterClientScriptInclude("ANTextBox", scriptMananger.GetWebResourceUrl(this.GetType(), resourceFilePath));
    
            if (this.Type == TextBoxType.Integer)
            {                
                if (_AllowNegative) { this.Text = "-"; }
                this.Attributes.Add("onkeydown", string.Format("return CheckOnlyInteger(event,this,'{0}');", _AllowNegative.ToString().ToLower()));               
            }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used this in my HTML: <q> Hai How r u </q> Which
hai I have a Spanish site in php. In this a mail body contain
Hai presently i have grid like this. <Grid Name=tGrid1 Grid.Row=0 Background=Black > </Grid> <Grid
hai Friends I am using this coding for validating the emailID online through webservice
Hai I have an application which is designed in netbeans6.0.1 where i need to
Hai I have developed a standalone application in which when an user logs in,
Hai all, In my iphone application i want to open a my custom application(available
Hai guys, How to include inline jquery scripts used in an aspx to a
Hai i developed a application in android,in my application i used a dynamically created
Hai i want to send the message via coding is it possible? mobile number=xxx

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.