0
我無法在for-each期間找到自定義用戶控件。無法在foreach中看到我的用戶控件
這是一個自定義用戶控件,這裏是我的代碼:
<uc2:MetaTag runat="server" id="MetaTag" SystemCode="TEXT" Text="test" />
但它確實找到文本控件,我有。
foreach (Control controlItemFound in Page.Controls)
{
Response.Write("Control Found: " + controlItemFound.GetType() + "<br);
if(controlItemFound is MetaTag)
{
MetaTag ctrl = (MetaTag)controlItemFound;
ctrl.Text = Server.HtmlDecode("MetaTag FOUND!!!");
}
if (controlItemFound is LiteralControl)
{
LiteralControl ctrl = (LiteralControl)controlItemFound;
ctrl.Text = Server.HtmlDecode("Server Text!");
}
}
很高興我能幫助的名稱 – Don