Re: usercontrols + code-behind
From: Alvin Bruney [MVP] (vapor)
Date: 03/02/04
- Next message: Alvin Bruney [MVP]: "Re: Threading in ASP.NET"
- Previous message: Alvin Bruney [MVP]: "Re: Application error"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Mar 2004 00:27:35 -0600
Your post went unanswered. Have you resolved this issue?
-- Regards, Alvin Bruney [ASP.NET MVP] Got tidbits? Get it here... http://tinyurl.com/3he3b "wh" <wayne@nospam.pyesmeadow.com> wrote in message news:lb5Xb.11676$q%6.4079675@newsfep2-win.server.ntli.net... > After spent a good half day looking for a solution I'm no further finding an > answer so I'd appreciate any ideas as to how this can be done. > > I have developed a user control that resides in a .ascx file with the > associated .ascx.cs file holding the code. Each .aspx page that uses this > control has appropriate <% Register %> directives at the top of the page: > > <%@ Register tagprefix="mytag" tagname="mycontrol" > src="usercontrols/mycontrol.ascx" %> > > The code-behind file (.aspx.cs) for each page has a reference to the class > (MyControl) that has been defined in the code-behind (.ascx.cs) file for the > control. > > protected MyControl myCtl; > > Currently, the project I'm working on is built using VS.NET and is thus > compiled as a single .DLL which sits in the BIN subdirectory. This works > FINE. > > The problem comes when I remove the .DLL that VS.NET builds and instead use > a 'SRC' attribute in the <%@ PAGE %> directive for each page. This allows me > to make changes to the code sitting in the code-behind file while at the > same time ensuring that the .NET Framework compiles any modifications on the > fly. This has worked well in the past. However, since adding the control to > the project, I now get an error whenever the .NET Framework compiles each > .aspx page containing the definition for the control: > > protected MyControl myCtl; > > I can't remember the exact error, but it's complaing that the 'MyControl' > type is not recognised. I know for a fact that it's in the same namespace as > the class in the code behind file for the .aspx page. It seems that .NET is > compiling the .ASPX page before the .ASCX page, and as a consequence knows > nothing about the MyControl class. > > I have tried using the <%@ Assembly %> and <%@ Reference %> directives in > the .aspx file without any success. > > Thanks, > Wayne. > >
- Next message: Alvin Bruney [MVP]: "Re: Threading in ASP.NET"
- Previous message: Alvin Bruney [MVP]: "Re: Application error"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|