KeyEventArgs e

C

Claudia Fong

I have the code below:

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
TextBox2.Text = "You Entered: " + textBox1.Text;
}
}

but when I build the website it gaves me an error of

The type or namespace name 'KeyEventArgs' could not be found (are you
missing a using directive or an assembly reference?)

Does someone know what I'm missing?

Cheers!

Claudi
 
T

Tom Porterfield

Claudia said:
I have the code below:

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
TextBox2.Text = "You Entered: " + textBox1.Text;
}
}

but when I build the website it gaves me an error of

The type or namespace name 'KeyEventArgs' could not be found (are you
missing a using directive or an assembly reference?)

Does someone know what I'm missing?

KeyEventArgs is in the System.Windows.Forms namespace (or
System.Windows.Input depending on what you are using for presentation)
but neither of those are included by default in a webpage.

Additionally, this appears to be server side code which would
potentially mean a postback on each keydown event. That would be a poor
experience for the user.

The web TextBox control only supports the TextChanged event server-side,
no key press type events.
 

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

Top