【问题标题】:How to get Div of Master Page in page in ASP.net?如何在 ASP.net 页面中获取母版页的 Div?
【发布时间】:2012-04-28 12:01:52
【问题描述】:
我在我的 Web 应用程序中使用母版页。现在我正在创建多个内容页面。
母版页中有一个带有标签的 Div。现在我想将该 Div 隐藏在一个内容页面中,而其他内容页面中的其他要求是获取 Div 内部的标签。
那么如何从内容页面隐藏母版页中的 Div 以及如何从内容页面获取该 Div 中定义的标签?
【问题讨论】:
标签:
asp.net
web-applications
html
master-pages
content-pages
【解决方案1】:
在母版页的 div 中添加属性:runat="server"
然后在内容页面中编写如下代码来访问该div:
Control c= this.Master.FindControl("masterDiv");// "masterDiv"= the Id of the div.
c.Visible = false;//to set the div to be hidden.
祝你好运!