asp.net 2.0 and a user control Parser Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having some major problems trying to get a user control working in
asp.net 2.0.

I have a user control in a sub directory of my project and I'm attempting to
put it on an aspx page. I'm getting an error like the following, though:

The base class includes the field 'MyUserControl', but its type
(Controls.MySubControls.MyUserControl) is not compatible with the type of
control (ASP.controls_mysubcontrols_myusercontrol_ascx).

The ascx is defined with:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="MyUserControl.ascx.cs"
Inherits="Controls.MySubControls.MyUserControl" %>


In the aspx, I reference the user control via something like:
<%@ Register TagPrefix="uc" TagName="MyUserControl"
Src="~/Controls/MySubControls/MyUserControl.ascx" %>

and later in the page via:
<uc:MyUserControl id="MyUserControl" runat="server" />


I'm stumped, so any help w/ this would be appreciated.

Thanks

Jim
 
Nevermind... I was adding the ascx to a custom control.

The custom control markup went like:
<uc:MyControl>
<Title>My Title</Title>
<Body>
<uc:MyUserControl id="blah" runat="server" />
</Body>
</uc:MyControl>

The title and body properties for that custom control were PlaceHolders. So
that is why the type of the ascx was getting screwed up with asp.net.

To anyone reading this looking for a work around, you can either subclass a
Panel and make the Title part an attribute. Or you can change the title and
body properties to be ITemplate types.

Jim
 
Back
Top