TextMode
doesn't have Number option. I know you see the option with intellisense but see this URL:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.textmode(v=vs.110).aspx
It can only have MultiLine
, SingleLine
or Password
. To get validation you are expecting you can use a CompareValidator
as mentioned below which will show the message if you enter anything other than numbers.
<asp:CompareValidator runat="server" ID="valNumber" ControlToValidate="tbPrice" Type="Integer" Operator="DataTypeCheck" ErrorMessage="You must enter a valid value." />
You can also use AjaxControlToolkit
control FilteredTextBox
. Which will not allow you to type anything else but number.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/FilteredTextBox/FilteredTextBox.aspx
The other option you have is to restrict user to only enter numbers. See below link:
How to allow only numeric (0-9) in HTML inputbox using jQuery?