1

我必须在 MasterPage 中找到所有 contentPlaceHolders 的 ID。

4

3 回答 3

1

遍历所有控件并递归地遍历它们的子控件并检查类型,如果它们是内容占位符,则您有 ID。

于 2009-02-05T09:49:05.863 回答
1

只需查询ContentPlaceHolders返回包含给定母版页中所有 CPH 名称的 IList 的属性。

VB代码:(对不起!)

'In the Master Page.
For Each cphID As String In Me.ContentPlaceHolders
  Debug.WriteLine(cphID)
Next
于 2009-02-05T10:13:09.713 回答
1

尝试:

for (string cphID in ((MasterPageType)this.MasterPage).ContentPlaceHolders)
{
   Debug.WriteLine(cphID);
}

在页面后面的代码中,将 MasterPageType 替换为母版页的类型

于 2009-02-05T10:53:24.297 回答