all groups > asp.net webcontrols > march 2007 >
You're in the

asp.net webcontrols

group:

Errors adding user control in web application


Errors adding user control in web application mbrundieck
3/30/2007 2:22:01 PM
asp.net webcontrols:
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:
[quoted text, click to view]

There are errors on the web page:
[quoted text, click to view]
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!
RE: Errors adding user control in web application mbrundieck
4/3/2007 10:02:03 AM
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. :)

[quoted text, click to view]
AddThis Social Bookmark Button