从其内容页面禁用母版页上的子菜单. [英] Disabling submenu on Master page from its content page.

查看:80
本文介绍了从其内容页面禁用母版页上的子菜单.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从其内容页面的母版菜单(Menu1)中禁用子菜单(submenu1)时,出现以下错误对象引用未设置为对象的实例".
代码是:-

I get the following error "Object reference not set to an instance of an object" when i try to disable a submenu(submenu1) in a masterpage menu(Menu1")from its content page.
The code is:-

Menu mastermenu = Master.FindControl("Menu1") as Menu;
MenuItem mi = mastermenu.FindItem("submenu1") as MenuItem;
submenu1.Enabled = false;


请帮助.
thnx


Plz help.
thnx

推荐答案

首先,您应该更新我们先前回答的关于您的最后一个问题:
如何创建子菜单项的对象(非菜单页面中的母版页? [
First of all you should had updated the last question of yours that we replied earlier:
How to create an object of submenu items(not menu control) of a masterpage in content page?[^]

Second, based on the code that you had written over here, you had not followed the reply nor the supporting link. You need to buy a book and clear your basics.


After doing:
Menu mastermenu = Master.FindControl("Menu1") as Menu;
MenuItem mi = mastermenu.FindItem("submenu1") as MenuItem;


你为什么要这么做?


Why had you done this?

submenu1.Enabled = false;



一旦获得"mastermenu"或"mi",就需要使用这两个对象进行操作.
类似的东西:



Once you get ''mastermenu'' or ''mi'', you need to play with those two objects to work on.
something like:

mi.Enabled = false;



在开始编写代码之前,请阅读/学习并理解C#的基本功能.



Please read/learn and understand the working of basic features of C# before starting to code.


这篇关于从其内容页面禁用母版页上的子菜单.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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