Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element <element> is not a known element warning in Visual Studio when using User controls

I have a Visual Studio 2008 project that is showing the following warning when using User Controls, and I haven’t been able to find a solution anywhere.

Element <element>is not a known element

How can I fix this?

like image 666
chris Avatar asked Jan 29 '09 15:01

chris


4 Answers

This sounds like a classic re-build your solution and "close and re-open Visual Studio" problem.

It's possible it may also be related to a similar problem I had which I answered at Resolving "Validation (): Element ‘xxxx’ is not supported" warning in Visual Studio 2005/2008.

like image 179
Jason Snelders Avatar answered Nov 04 '22 20:11

Jason Snelders


This can also occur if the element you're trying to add is within the tags of another element that it shouldn't be within.

For Example:

<asp:Button ID="button" runat="server" >
    <asp:Repeater ID="repeater" runat="server"></asp:Repeater>
</asp:Button>

Or in my case, placing an <asp:Repeater> in an <asp:UpdatePanel> and forgetting to put it in the <ContentTemplate>:

<asp:UpdatePanel ID="upPanel" runat="server">
    <ContentTemplate>
        <asp:Repeater ID="rep" runat="server">

        </asp:Repeater>
    </ContentTemplate>
</asp:UpdatePanel>
like image 32
Jerreck Avatar answered Nov 04 '22 19:11

Jerreck


Apparently this can also happen if the Namespace name in the .ascx file doesn't match the namespace in the ascx.cs (codebehind) file. Just one more issue to check.

like image 25
Glade Mellor Avatar answered Nov 04 '22 21:11

Glade Mellor


From the OP:

The apparent solution to this is to make sure that the TagName is the name of control class.

So for my example, the following displayed the warning:

<%@ Register Src="~/path/to/Control.ascx" TagName="tagName" TagPrefix="tagprefix" %>

<tagprefix:tagName runat="server" id="controlID" />

But changing it to:

<%@ Register Src="~/path/to/Control.ascx" TagName="Control" TagPrefix="tagprefix" %>

<tagprefix:Control runat="server" id="controlID" />

fixes it.

like image 3
TylerH Avatar answered Nov 04 '22 19:11

TylerH