473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

The type or namespace name 'KeyPressEventArgs' could not be found

What do I have to import at the top of my aspx page (c#) when getting this
error message?

i tried <% Import namespace="System.Windows.Forms.KeyPressEventArgs" %>

but it erros something along the lines of 'Windows not recognised in System'
I'm not sure I understand how to include classes. I'm only trying to
recognise an enter key pressed in a text box.
Nov 18 '05 #1
3 10222
Louise,
You seem to be trying to mix WinForms and WebForms, which you can't. The
Textbox in asp.net is an instance of System.Web.UI.WebControls.TextBox,
which is not the same as in winforms (System.Windows.Forms.TextBox). The
ASP.Net one doesn't expose a KeyPress event, and if it did, the event
argument surely wouldn't be found in System.Windows.Forms*, but rather in
System.Web.UI.*

System.Web.UI.TextBox exposes a TextChanged event and that's pretty much it.
If you want to catch OnKeyPress you'll need to use javascript on the client.

The error you are getting is because you didn't reference
System.Windows.Forms to your code, which defines the System.Windows*
namespace. As such, System.Windows* is unrecognized. Again, simply adding
the reference might remove that error, but it won't work like you want
(winforms != webforms).

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:D1**********************************@microsof t.com...
What do I have to import at the top of my aspx page (c#) when getting this
error message?

i tried <% Import namespace="System.Windows.Forms.KeyPressEventArgs" %>

but it erros something along the lines of 'Windows not recognised in System' I'm not sure I understand how to include classes. I'm only trying to
recognise an enter key pressed in a text box.

Nov 18 '05 #2
Hi Louise.

If you try to develop a web site using asp.net then please describe in more
details what you're trying to do. None of asp.net controls have KeyPress or
KeyUp or KeyDown events. If you develop a desktop app (as your use of
System.Windows.Forms namespace implies) than you're in a wrong newsgroup :)

Regards,
Kikoz
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:D1**********************************@microsof t.com...
What do I have to import at the top of my aspx page (c#) when getting this
error message?

i tried <% Import namespace="System.Windows.Forms.KeyPressEventArgs" %>

but it erros something along the lines of 'Windows not recognised in
System'
I'm not sure I understand how to include classes. I'm only trying to
recognise an enter key pressed in a text box.

Nov 18 '05 #3
didnt realise you couldnt use these events such as keypress on server
controls. makes sense as they are client events. sorry will think more in
future.

"Kikoz" wrote:
Hi Louise.

If you try to develop a web site using asp.net then please describe in more
details what you're trying to do. None of asp.net controls have KeyPress or
KeyUp or KeyDown events. If you develop a desktop app (as your use of
System.Windows.Forms namespace implies) than you're in a wrong newsgroup :)

Regards,
Kikoz
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:D1**********************************@microsof t.com...
What do I have to import at the top of my aspx page (c#) when getting this
error message?

i tried <% Import namespace="System.Windows.Forms.KeyPressEventArgs" %>

but it erros something along the lines of 'Windows not recognised in
System'
I'm not sure I understand how to include classes. I'm only trying to
recognise an enter key pressed in a text box.


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew Louden | last post by:
using System.Data; using System.Data.SqlClient; //etc... SqlConnection conn = new SqlConnection(connString); SQLDataSetCommand myCmd = new SQLDataSetCommand("select * from Test;", conn);...
8
by: Chris Smith | last post by:
Experience posters, I am an experienced vb/vb.net developer but having a bit of trouble converting a bit of code to C#. I have 3 projects in one solution. Trying to create a plug-in type...
1
by: Randall Parker | last post by:
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb question. I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind C# source file...
7
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
2
by: AnalogKid17 | last post by:
Keywords: ASP.NET app with VS2005 running on Win2003 with IIS6, and SQL2000 on a WinXP Box I've betting the following for days... it's driving me insane: Server Error in '/' Application. ...
6
by: antonyliu2002 | last post by:
Hi, guys, I am using Visual Web Developer Express 2005 for my web application. I wrote a simple class called MyTestClass.cs and put it in the App_Code folder. I compiled it to library from...
2
by: Andrus | last post by:
I'm trying to compile myGeneration PropertyCollectionAll.cs file with VCS Express 2005 bot got error Error 1 The type or namespace name 'Collection' could not be found (are you missing a using...
5
by: mknoll217 | last post by:
I am a newbie at XML. I have been given an xml document that I need to write the schema for, for a class assignment. The xml given to me is <?xml version="1.0"?> <Vendors> <Vendor> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.