如何获取内容页面中的母版div [英] how to get the masterpage div in the content page

查看:91
本文介绍了如何获取内容页面中的母版div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中使用母版页。现在我正在创建多个内容页面。 Master页面中有一个Div有标签。现在我想隐藏在一个内容页面中的Div和其他内容页面中的其他要求是获得Div内的标签。



那么如何隐藏Div哪个在主页面中,从内容页面以及如何获取在内容页面中划分的标签?

I am using Master Page in my Web Application. Now i am creating multiple content pages. there is one Div in the Master page which had label. Now i want to hide that Div in one content page and other requirement in other content page is to get label which is inside the Div.

So How to hide Div which is in Master Page, from Content Page and how to get label which is defined in that Div from Content page?

推荐答案

您应该是能够使用以下语法从内容页面获取位于母版页中的控件对象的引用:





You should be able to get a reference to the control object which is located in master page from your content page using syntax like this:


HtmlGenericControl yourDiv = this.Master.FindControl("yourDiv") as HtmlGenericControl;
Label yourlbl = this.Master.FindControl("yourlbl") as Label;





但是请注意,要获得对div控件的引用,你应该在div声明中有一个runat =server,即它实际上是服务器端的html控件。



问候

Pawan



However please note that to get a reference to your div control you should be having a runat="server" in the div declaration i.e., it is actually a server side html control.

Regards
Pawan


这篇关于如何获取内容页面中的母版div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆