| Author: Gaurav Agrawal 01 Jan 2009 | Member Level: Diamond | Rating: Points: 1 |
use masked textbox in windows application for do this
GA
Thanks & Regards,
Gaurav Agrawal Sr.Software Engineer gaur1982@yahoo.com 09829373514
|
| Author: Deepika Haridas 01 Jan 2009 | Member Level: Diamond | Rating:   Points: 3 |
Hi,
Try this
private bool txtNumericStringIsValid() { if (txtpin.Text == string.Empty) { return true; } char[] testArr = txtpin.Text.ToCharArray(); bool testBool = false; for (int i = 0; i < testArr.Length; i++) { if (!char.IsNumber(testArr[i])) { testBool = true; } } return testBool; }
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|
| Author: divya 01 Jan 2009 | Member Level: Gold | Rating: Points: 1 |
Hi Try this <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please enter a numeric value guests ." ValidationExpression="^\d+(\.\d+)?$" >*</asp:RegularExpressionValidator>
|
| Author: Rahul 01 Jan 2009 | Member Level: Silver | Rating:   Points: 3 |
In the keypress event of textbox write below code..
If (char.IsDigit()) then e.handled=true else e.handled=false End if
The keypress event will be be fired every time u press any of the key
and TextBox will accept only numbers u have entered.
|
| Author: Ranish 02 Jan 2009 | Member Level: Bronze | Rating: Points: 1 |
if (!Char.IsControl(e.KeyChar)) { e.Handled = !Char.IsDigit(e.KeyChar); }
|
| Author: AMARJIT SINGH 07 Jan 2009 | Member Level: Gold | Rating: Points: 1 |
Hello friend,
Here is a solution i am writing to you. The code restricts as user to enter any letter in the textbox,i.e. only digits can be entered by this code.
Here is the solution ---------------
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar.IsDigit(e.KeyChar) = False And Asc(e.KeyChar) <> 8 Then If Asc(e.KeyChar) = 13 Then MsgBox("Please focus to next control.") Exit Sub End If e.Handled = True MsgBox("Please Enter only digits") End If End Sub
---------
Enjoy programming. AMARJIT SINGH.
|
| Author: Sajith G.S. 14 Jan 2009 | Member Level: Bronze | Rating: Points: 1 |
Hello friend,
Use Ajax FilteredTextBoxExtender to do this,
<ajaxToolkit:FilteredTextBoxExtender id="FilteredTextBoxExtender2" runat="server" TargetControlID="txtCCNo" FilterType="Numbers"></ajaxToolkit:FilteredTextBoxExtender>
(FilterType="Numbers") means that textbox only allows integer values..
|