Errors adding user control in web application

Discussion in 'ASP .Net Web Controls' started by mbrundieck, Mar 30, 2007.

  1. mbrundieck

    mbrundieck Guest

    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!
    mbrundieck, Mar 30, 2007
    #1
    1. Advertising

  2. mbrundieck

    mbrundieck Guest

    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/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!
    >
    mbrundieck, Apr 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    927
    Mark Goldin
    Jan 17, 2004
  2. Amil
    Replies:
    0
    Views:
    368
  3. ABC
    Replies:
    1
    Views:
    2,626
    Larry
    Oct 4, 2005
  4. Replies:
    1
    Views:
    724
    Sean Chambers
    Oct 11, 2006
  5. Travis Pruitt

    Dynamically Adding User Control with Child User Control

    Travis Pruitt, Jan 13, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    173
    Travis Pruitt
    Jan 13, 2005
Loading...

Share This Page