type '' is not defined

L

Lew Burrus

I am relatively new to advanced concepts in
OOP, though I am fairly comfortable working
in .Net. Have recently taken a 1.1 project
into VS2005, and came across a show-stopper
of an error. When I create a variable of
another page's class type, the class is no
longer available, as I get the error "Type
'userControl' is not defined".

In other words, I have a page
displayRecs.aspx, and a user control
subRecords.ascx. In the main page, I need to
dim a variable as type subRecords; it worked
fine in 1.1, but in 2.0, I get the error. I
assume the compilation model requires
separate assemblies for each page, so the
classes aren't available until runtime. But
it seems like this could be a real hindrance
for many developers, and I image a workaround
must exist. Anybody know of one? Is this a
bug to be fixed, or a permanent change in .Net?

Lew
 
C

Chris Jobson

Lew Burrus said:
I am relatively new to advanced concepts in OOP, though I am fairly
comfortable working in .Net. Have recently taken a 1.1 project into
VS2005, and came across a show-stopper of an error. When I create a
variable of another page's class type, the class is no longer available, as
I get the error "Type 'userControl' is not defined".

In other words, I have a page displayRecs.aspx, and a user control
subRecords.ascx. In the main page, I need to dim a variable as type
subRecords; it worked fine in 1.1, but in 2.0, I get the error. I assume
the compilation model requires separate assemblies for each page, so the
classes aren't available until runtime. But it seems like this could be a
real hindrance for many developers, and I image a workaround must exist.
Anybody know of one? Is this a bug to be fixed, or a permanent change in
.Net?

I'm just learning ASP.NET 2 myself, but I think if you move your user
control into the App_Code folder your proiblem will go away (if your project
doesn't have such a folder yet, right-click on the root in the Solution
Explorer, then select "Add ASP.NET Folder" then "App_Code"). Note that you
will also have to change the register directive on all the pages that use
the control to something like:
<%@ Register Src="App_Code/subRecords.ascx .......

Chris Jobson
 

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