Is this a documentation or .Net problem?

  • Thread starter Thread starter Ken Allen
  • Start date Start date
K

Ken Allen

I want to place an edit control (TextBox) on a form and restrict it to
numeric vlaues. The documentation indicates that [myTextBox.Numeric = true]
should do thios, but the C# compiler complains that "Numeric" is not a
member or property of TextBox!

-Ken
 
Ken Allen said:
I want to place an edit control (TextBox) on a form and restrict it to
numeric vlaues. The documentation indicates that [myTextBox.Numeric = true]
should do thios, but the C# compiler complains that "Numeric" is not a
member or property of TextBox!

What kind of TextBox are you using? Numeric is only a property on the
mobile ASP.NET type of TextBox.
 
Try the following. Wire it up the the keyPress event
handler:

private void NumericTextBox_KeyPress(object sender,
KeyPressEventArgs e)
{
int intVal = (int)e.KeyChar;

//1st Check for numbers
if ( intVal < 48 || intVal > 57 )
{
switch ( intVal )
{
case 8: // Backspace
break;

default:
e.Handled = true;
break;
}
}
}
 
i think the Numeric property is supported only by the mobile control
and not by web control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top