Re: usercontrols + code-behind

From: Alvin Bruney [MVP] (vapor)
Date: 03/02/04


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.
>
>


Relevant Pages

  • Re: usercontrols + code-behind
    ... Each .aspx page that uses this ... > control has appropriate directives at the top of the page: ... protected MyControl myCtl; ... I now get an error whenever the .NET Framework compiles each ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • usercontrols + code-behind
    ... I have developed a user control that resides in a .ascx file with the ... Each .aspx page that uses this ... same time ensuring that the .NET Framework compiles any modifications on the ... I can't remember the exact error, but it's complaing that the 'MyControl' ...
    (microsoft.public.dotnet.framework.aspnet)
  • usercontrols + code-behind
    ... I have developed a user control that resides in a .ascx file with the ... Each .aspx page that uses this ... same time ensuring that the .NET Framework compiles any modifications on the ... I can't remember the exact error, but it's complaing that the 'MyControl' ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: passing variables from .aspx.cs code pages to .aspx pages
    ... snippet, I've got the cause of your problem, for ASP.NET server control, we ... in the aspx page's inline template, but we can adjust those parameters' ... Microsoft Online Support ... |> | protected void Page_Load ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Suppress Form Action
    ... A custom server control has a Button. ... Private strConfirmMsg As String ... Public Property ConfirmMessageAs String ... using the above custom control in an ASPX page (assume that the ASPX ...
    (microsoft.public.dotnet.framework.aspnet)

Quantcast