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.
Check you might be on ContentPlaceHolderID="MainContent" on Asp.net, so place the code on a new placeholder
I found that the issur was resolved when I changed the Build Action from "content" to "compile" for the .ascx file and afterwards chaned it back.
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.
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.
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>
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.