2
我不想有两个母版页,所以我想这样做(留出了<%%>的可读性):如何在ASP.NET中创建两个具有相同ID的ContentPlaceHolder?
if (a == b)
{
<asp:ContentPlaceHolder ID="X" runat="server" />
}
else
{
<div class="c">
<asp:ContentPlaceHolder ID="X" runat="server" />
</div>
}
但它不会让我:
Duplicate ContentPlaceHolder 'X' were found. ContentPlaceHolders require unique IDs.
于是,我就用ID设定的ID = “<%= ”X“ %>” 不,不会让我可以:
Server tags cannot contain <% ... %> constructs.
然后我试图<%#的eval(” X“)%>和n开放:
The ID property of a control can only be set using the ID attribute in the tag and a simple value. Example: <asp:Button runat="server" id="Button1" />
有什么办法来实现我想要做的?我想这样
echo '<asp:ContentPlaceHolder ID="X" runat="server" />'
或一些动态的方式来添加标签,因为显然解析器无法识别的if else块,不会让两个标签具有相同的ID。
我使用默认视图引擎的MVC。
优秀。这就是为什么 - 我不认为这个答案。 – sker 2011-06-13 15:34:21