Reputation: 167
I commented out my table in HTML code. Although the table does get removed, the control inside it seems to persist.
<div>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" ForeColor="#0066CC"></asp:Label>
<!--
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" ForeColor="#0066CC"></asp:Label>
</td>
</tr>
</table>
-->
</div>
When I run my application, visual studio give me an error:
The ID 'Label1' is already used by another rcontrol.
I do not know why visual studio still checks the control inside the commented out portion of my HTML. Does anybody have any clue on this matter? Thanks in advance!
Upvotes: 2
Views: 237
Reputation: 39501
That is html comment, not the asp.net server side comment. You should use <% -- code --%>
<%--
Commented out HTML/CODE/Markup. Anything with
this block will not be parsed/handled by ASP.NET.
<asp:Calendar runat="server"></asp:Calendar>
<%# Eval(“SomeProperty”) %>
--%>
Take a look at Scott Guthrie's post
Upvotes: 9