是否可以通过代码在ContentPlaceHolder中设置数据?这就是我的想法:

dim oCPH as new ContentPlaceHolder
oCPH.id = "column1" 'this id is the one that corresponds with the ID I set on the page
oCPH.content = "content here" '<-- not real code

显然这不是正确的语法,我希望这澄清了我的要求。

有帮助吗?

解决方案

您应该能够通过当前页面上的Master Page元素引用它。类似的东西:

ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("column1");

如果在后面的母版页代码中,只需按名称引用它。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top