ASCX designer file not linking - nest related files

S

Steven Nagy

Hi all,

ASP.NET : Framework 2.0 - C#

A recent addition to my code generater will create GridView's and
ObjectDataSource's in a control (ASCX).
So the code gen creates an ascx, ascx.cs, ascx.designer.cs and a
stylesheet.
The 3 control files are placed together.

When generating for project A, the control files (after refresh)
appear all nested properly, eg.
+ TestGrid.ascx
- TestGrid.ascx.cs
- TestGrid.ascx.desginer.cs

... and compiles nicely and works perfectly.

I now wanted to use it for another project (B), but when refreshing
the files in the website, only the .ascx.cs file nests under the .ascx
file. The designer file does not nest; it simply sits at the same
level as the ascx. Clicking "nest related files" over and over makes
no difference.

Project B also does not build. The error is as follows (where UserGrid
is the name of the control):
"Could not load type: 'ICMWeb.UserGrid'
.... and this error occurs on line 1 of the ASCX file (the @
directive). THe code behind file is correct, and the inherits
attribute is also correct.

This error naturally occurs for every control I generate.
Also, when I delete ALL asp code from the .ascx file except for the
directive, it still fails.

So I suspect that the 2 issues are related: the fact that VS doesn't
think that the designer file is the same as the .ascx.cs file (even
though they are both partial classes and have the same name) and the
fact that it can't compile because of a problem with the type
(whatever that means).

Any suggestions?
Does anyone know the criteria that VS uses to nest related files? This
could lead in to identifying the problem.
Also, what's happening with namespaces here? When I create a new site,
pages I add are not namespaced, but the controls I generated ARE
namespaced. Web sites in 2.0 don't let you specify a default
namespace. This could also be related. However, the namespace for the
designer, ascx, and ascx.cs files are all the same.

Any help is appreciated.

Thanks,
Steven
 
M

Mark Fitzpatrick

Are you using the same project types all around? Keep in mind, there are 2
project types for ASP.Net, the Web Site project that came originally with
VS.Net 2005, and the new Web Application project, which is a port of the VS
2002/3 Web Applicaiton project and available in VS.Net Service Pack 1. Web
Application projects nest files in the exact manner you describe. The
designer and code behind pages are a function of the root aspx page so the
designer is not a function of the code behind and thus appears at the same
level.

When do you receive the error regarding ICMWeb.UserGrid, is it during the
build process, or when you attempt to view the page after a build. If you
are viewing the page after a build and getting this error it is exactly
correct. The error occurs because something within that page is preventing
it from building. You may want to add the Output window to the project as it
will often show errors in the build process that you may now catch
otherwise.
 
S

Steven Nagy

Hi Mark,

It is definately a web site. Although I do have the web app template
installed, I am not using it.
Also, this error occurs during build. I found this funny because I am
not use to build errors occuring on ASPX or ASCX files.

Further investigation shows this. I added a new web control to my
project. This file obviously does not cause any errors during build.
Secondly, I stripped back one of MY offending ASCX files so that it
only had its directive, and 1 code behind file, which only had the the
Load method, exactly the same as the new control. The two controls are
IDENTICAL except for their class names. Still I get the error.

So next I deleted all other files in the project so that there is only
1 offending control, stripped down with nothing in it, and the new
control I added that works fine.
Still I get this error.

So now I am thinking it must be some sort of caching issue. Output
window doesn't reveal anything other than this:
E:\Work\Projects\Internet Connection Monitor\ICMWeb\Controls\Grids
\SettingGrid.ascx(1): Build (web): Could not load type 'SettingGrid'.

This is the code for the control:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="SettingGrid.ascx.cs" Inherits="SettingGrid" %>

This is the code for the code behind file:
public partial class SettingGrid : System.Web.UI.UserControl { }

Not sure what else to try.
Any more ideas?

Thanks,
Steven
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top