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?
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.
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>
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With