如何在内容页面中创建母版页的子菜单项(而非菜单控件)的对象? [英] How to create an object of submenu items(not menu control) of a masterpage in content page?

查看:51
本文介绍了如何在内容页面中创建母版页的子菜单项(而非菜单控件)的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在各个级别上创建子菜单项的对象(而非菜单控件),并从其内容页面禁用特定的子菜单?
问候.

How do create an object of submenu items (not menu control) at various levels and disable a particular submenu from its content page?
Regards.

推荐答案

您可以访问母版页控件.您始终可以通过"this.Master"从其内容页面访问母版页.

您可以通过母版页"的属性来满足各种需求.
如果需要访问控件,则可以使用:
this.Master.FindControl()

获得控件后,将其转换为有效类型并可以访问该控件的所有有效属性.

Google将此链接作为第一个链接,以便在需要时提供更多参考:
从内容"页中的访问母版页成员ASP.Net [ ^ ]
You can access master page controls. You always have access to Master page from its content page through "this.Master"

You can expose various needs through properties of Master Page.
If you need to access the control then you can use:
this.Master.FindControl()

Once you get the control, cast it into valid type and have an access to all the valid properties of that control.

Google gave this as first link for more reference if needed:
Accessing Master Page Members from Content Pages in ASP.Net [^]


您得到的另一个答案是正确的,但是我想为我的ASP.NET页面创建一个基类.它封装了获取我的母版页类的强类型实例的所有丑陋之处.然后,我不需要Findcontrol,可以在母版页实例上调用公共方法,而不仅仅是通用基本方法.
The other answer you got is correct, but I like to create a base class for my ASP.NET pages which encapsulates all the ugliness of getting ahold of a strongly typed instance of my master page class. Then I don''t need Findcontrol, I can call public methods on the instance of my masterpage, instead of just the generic base methods.


这篇关于如何在内容页面中创建母版页的子菜单项(而非菜单控件)的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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