Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to enable a textbox for numbers only in asp.net.without using script andexpression validator
Posted
Comments
ridoy 28-Sep-12 1:35am    
right

Hi,
U can use "FilteredTextBoxExtender". it is a ajax toolkit extender control.
Set property FilterType="Numbers"

u can refer follwing link for that:
http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/[^]
 
Share this answer
 
You can done this in following ways:
AjaxFilteredTextBoxExtender

here you first add reference of ajax toolkit and this extender.
you can set ValidChars to "." for decimal which allo user to enter numeric value with decimal point.
Collapse | Copy Code
<ajaxtoolkit:filteredtextboxextender id="ftbe" runat="server" xmlns:ajaxtoolkit="#unknown">
TargetControlID="TextBox3"
FilterType="Numbers"
/>
 
Share this answer
 
Hi,

See the below link. It might be help you to find your solution.

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/FilteredTextBox/FilteredTextBox.aspx[^]

Set FilterType="Numbers" for enter only numeric values.

Thanks,
Viprat
 
Share this answer
 
v2
Friend, use the custom code on KeyPress event of text box... let me know if you required the code for same.
Thanks,
Ambesha
 
Share this answer
 
hiii try this


1)
XML
<asp:TextBox ID="txtNumbers" runat="server"/>

   <asp:FilteredTextBoxExtender ID="Numbers"

                runat="server"

                TargetControlID="txtNumbers"

                FilterType="Numbers">

  </asp:FilteredTextBoxExtender>


2)

XML
<script language="javascript" type="text/javascript">
function intOnly(i)
{
if(i.value.length>0)
{
i.value = i.value.replace(/[^\d]+/g, '');
}
}
</script>

<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 240px; POSITION: absolute; TOP: 152px" Runat="server" onChange="intOnly(this);" onKeyUp="intOnly(this);" onKeyPress="intOnly(this);"></asp:TextBox>
 
Share this answer
 
Comments
Shibiny 28-Sep-12 2:33am    
when i use filtered textboxextender i got this error
"Unknown server tag 'asp:FilteredTextBoxExtender'. "
Ganesh Nikam 28-Sep-12 2:37am    
hey add ajax filtertextboxextender to your page and
use it steps are
here

http://www.c-sharpcorner.com/uploadfile/prathore/ajax-filteredtextboxextender/
Ganesh Nikam 28-Sep-12 4:36am    
got your ans?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900