for the textbox if i want to allow only numbers.what ever
the characters u enter it should not take.which event u used?

Answers were Sorted based on User's Feedback



for the textbox if i want to allow only numbers.what ever the characters u enter it should not take..

Answer / chandra sekhar

@kinjal what is the use of using compare validator here??
and with what yopu are comparing the value?? your answer is
absolutely wrong.

If we want to allow only integers into a textbox then use
"^\d{0,9}" expression.

ex: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1"
ErrorMessage="RegularExpressionValidator"
ValidationExpression="^\d{0,9}"></asp:RegularExpressionValidator>

Is This Answer Correct ?    11 Yes 1 No

for the textbox if i want to allow only numbers.what ever the characters u enter it should not take..

Answer / kinjal

if u r using web application then take one textbox and use comparevalidator

set properties of comparevalidator .

<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox1"

Display="Dynamic" ErrorMessage="Integer required."
Operator="DataTypeCheck" SetFocusOnError="True"

Type="Integer"></asp:CompareValidator>

Is This Answer Correct ?    13 Yes 10 No

for the textbox if i want to allow only numbers.what ever the characters u enter it should not take..

Answer / j

use mask textbox

Is This Answer Correct ?    1 Yes 2 No

for the textbox if i want to allow only numbers.what ever the characters u enter it should not take..

Answer / yusuf khan

You will also use ajax FilteredTextBoxExtender and in filter
type allows only number like this

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<asp:FilteredTextBoxExtender
ID="FilteredTextBoxExtender1" runat="server"
TargetControlID="TextBox1" FilterType="Numbers">
</asp:FilteredTextBoxExtender>

Is This Answer Correct ?    0 Yes 1 No

for the textbox if i want to allow only numbers.what ever the characters u enter it should not take..

Answer / anjaan

Three events are triggered when a key is pressed and
released:
keydown
keypress
keyup
The keydown event occurs when the key is pressed, followed
immediately by the keypress event. Then the keyup event is
generated when the key is released.
In order to understand the difference between keydown and
keypress, it is useful to understand the difference between
a "character" and a "key". A "key" is a physical button on
the computer's keyboard while a "character" is a symbol
typed by pressing a button. In theory, the keydown and
keyup events represent keys being pressed or released,
while the keypress event represents a character being typed.

Is This Answer Correct ?    8 Yes 10 No

Post New Answer

More Dot Net General Interview Questions

How to manage pagination in a page using .net?

0 Answers  


Compare client server application with n-tier application

0 Answers  


How is a property designated as read-only?

2 Answers   Siebel Systems,


Can u explain me What is encapsulation?

7 Answers   Deloitte, GK companies,


What is the managed and unmanaged code in .net?

3 Answers   Deltech, Dhanush Infotech,






what is assembly?

2 Answers   Manhattan,


If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?

0 Answers  


Explain the difference between the stack and the heap?

0 Answers  


Is .net 4.8 backwards compatible?

0 Answers  


Which file is taken by compiler when we have both file Application and Server Configuration file?

0 Answers  


How will you make .NET programs work in Linux ?

0 Answers  


what is the use of stored procedure which has only one select statement over simple select statment query ? Why to write a stored procedure then ?

3 Answers  


Categories