通过代码ASP.NET设置ContentPlaceHolder数据

发布于 2024-07-06 16:44:27 字数 283 浏览 6 评论 0原文

是否可以通过代码设置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

显然这不是正确的语法,我希望这能澄清我的问题。

Is it possible to set the data in a ContentPlaceHolder through code? This is what I am thinking of:

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

Obviously that is not correct syntax, I hope that this clarifies what I am asking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨小墨 2024-07-13 16:44:27

您应该能够通过当前页面上的 MasterPage 元素引用它。 类似于:

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

如果在 MasterPage 代码隐藏中,只需按名称引用它。

You should be able to reference it through the MasterPage element on the current page. Something like:

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

If in the MasterPage codebehind, just reference it by name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文