在母版页代码隐藏中呈现 ASP.NET 控件
我在我的母版页中使用 Substitution 控件,并且我想在 Substitution 中呈现用户控件内容(与我的网站的登录区域相关)。 似乎我必须有所请求页面的引用,以便它可以呈现控件。但我需要在母版页本身中呈现控件,因为它在我的网站中的多个页面之间共享。实现这一目标的指导方针是什么?
塔克斯
I'm using a Substitution control in my master page, and I want to render a user control content (related to the login area of my website) in the Substitution .
Seems like I must have a reference for the requested page so that it could render the control. But I need to render the control in the master page itself, as it's shared across multiple pages in my website. What are the guidelines to achieve that?
Tks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想从 MasterPage 代码隐藏中呈现用户控件,并将其添加到母版页中的 Substitution 中吗?为什么需要对使用母版的页面的引用?
假设您使用 VB 并且我理解您的问题,请在您的 MasterPage 代码隐藏中尝试以下操作:
So you want to render a user control from your MasterPage code-behind, and add it to a Substitution that's also in the master page? Why do you need a reference to the page that's using the master?
Assuming your using VB and that I understand your question, try this in your MasterPage code-behind: