Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Errors adding user control in web application

Reply
Thread Tools

Errors adding user control in web application

 
 
mbrundieck
Guest
Posts: n/a
 
      03-30-2007
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/lib...5f(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!

 
Reply With Quote
 
 
 
 
mbrundieck
Guest
Posts: n/a
 
      04-03-2007
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.

"mbrundieck" wrote:

> 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/lib...5f(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!
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a web user control to a web control library rsam2011@yahoo.com ASP .Net 1 10-11-2006 03:22 AM
Web User Control with GridView can derive new Web User Control? ABC ASP .Net 1 10-04-2005 12:29 PM
Dynamically Adding User Control with Child User Control Travis Pruitt ASP .Net Building Controls 0 01-13-2005 08:49 PM
Project Architecture - Adding new user control to existing web application Amil ASP .Net 0 04-05-2004 05:28 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments