asp.net 2.0 and a user control Parser Error

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
 
G

Guest

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
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top