在 C# 中获取 ContentPlaceHolder 的内容
我有一个包含多个 ContentPlaceHolders 的母版页。其中之一有时会是空的。如果它们都有内容,我想使缓冲区可见,以便它们之间有一些空间,但否则应该保持隐藏。
我的问题是,如何从母版页的 C# 代码隐藏中确定子页面的 ContentPlaceHolder 是否分配有任何内容?我真正想要的是一个布尔是/否答案。
谢谢!
I've got a Master Page with multiple ContentPlaceHolders. One of them will sometimes be empty. If they both have content, I'd like to make visible a buffer so there is some space between them, but this should remain hidden otherwise.
My question is, how can I determine from the C# code-behind of my Master Page whether the ContentPlaceHolder of a child page has any content assigned to it? All I really want is a boolean yes/no answer.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许
这对你有用吗?
perhaps
Would that work for you?
也许我错过了一些东西,但看来你只需要留出空间。为什么不直接用
padding-bottom
将第一个 ContentPlaceHolder 包装在div
中?可能有更有效的方法来做到这一点,但你明白了。Maybe I am missing something, but it seems you just need to get spacing. Why not just wrap the first ContentPlaceHolder in a
div
with apadding-bottom
? There may be a more efficient way to do this, but you get the idea.您可以以编程方式将 div 添加到您的第一个 ContentPlaceHolder 中,其中包含...
并且在您的 css 中有这样的...
您可能需要在 div 中放置一个
来解决一些浏览器错误:)
You could programmatically add a div to your first ContentPlaceHolder with something like ...
and in your css have this ...
you may need to put a
in the div to get around some browser bugs :)