我们有两个占位符,只有一个是可见的,可见性是在页面加载期间设置的。
<%@ Register TagPrefix="cecontrols" Namespace="Controls" Assembly="Components" %>
在每个占位符内,是标签:(注意每个的 ID 不同,但 File 属性值是相同的)
<cecontrols:Include ID="IE7MessageDisabled" runat="server" File="/IE7-Message.ascx" />
和
<cecontrols:Include ID="IE7MessageEnabled" runat="server" File="/IE7-Message.ascx" />
这工作正常,直到用户向页面发出 POST,然后我们得到 500 错误:
为什么 POST 会导致这种情况?我们如何解决这个问题?
<error host="" type="System.Web.HttpException" message="Multiple controls with the same ID 'IE7-Message' were found. FindControl requires that controls have unique IDs." source="ExcptManag" detail=" at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
 at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
 at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
 at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
 at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
 at System.Web.UI.Page.FindControl(String id)
 at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)" time="2013-10-03T06:53:06.437Z" />