Errors adding user control in web application

M

mbrundieck

Hi,
I have a web user control that was built in one project that I want to add
to my ASP.Net 2.0 web application project. I know what I'm trying to do will
work fine in a Web Site project, but I don't want to convert my project to
Web Site project to accomplish this.

I have tried using the web config in the following way:
<pages>
<controls>
<add tagPrefix="uc" namespace="UI.Controls" assembly="UI.Controls"/>
</controls>
</pages>
then adding my control to a page:
<uc:Filter id="Filter1" runat="server"></uc:Filter>

And I have tried using the register directive with the control as shown above:
<%@ Register TagPrefix="uc" TagName="Filter" Src="~/Controls/filter.ascx"
Assembly="UI.Controls" Namespace="UI.Controls" %>

The UI.Controls.dll is in the bin directory.

I only have the ascx control in the web application project and not the code
behind (since it is in the DLL).

There is errors on the filter.ascx:
UI.Controls.Filter is not accessible in this context because it is 'Private'
'Context' is not a member of 'ASP.controls_filter_ascx'

There are errors on the web page:
'UI.Controls.Filter' is inaccessible due to its protection level
'Unrecognized tag prefix 'uc'
(design error): 'namespace' attribute is not supported on this directive
when a 'tagname' attribute is present.

So regarding the last error, if I remove 'tagname', then compile, it says
'tagname' is missing. That helps! ;)

This problem with being inaccessible, I followed a walk through
(http://msdn2.microsoft.com/en-us/library/yhzc935f(VS.80).aspx) and tried to
follow those steps and that didn't help. I think that was only for Web Site
projects.

This is only a representation of hours of searches and retries that have
been fruitless. Please let me know if I shouldn't be trying this in a Web
Application project and copy the codebehind in the project, or if there is
something that I can correct.

Thanks in advance!
 
M

mbrundieck

Perhaps "Filter" conflicts with something.

I started with a fresh c# web application project with a default page and a
fresh VB web application project that I created a control. I would build the
VB web control without a problem. Copy the ASCX to the C# project and add the
DLL of the VB project to the C# project references. I could drag the control
from the solution explorer to the design view of the default page. Build and
run without problems. But if I use "Filter" for the name of the ASCX page
(thus also for the Tagname), then it would complain that it is not a known
element.

At least I'm glad that VB web controls can be used in a C# web application. :)
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top