本文介绍了如何禁用导航菜单控件的子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在母版页上有navigarionmaenu控件。这个母版页适用于某些页面。(例如,Add.aspx,login.aspx)



现在我需要在添加时禁用某些导航菜单控件的子项.aspx。

我该怎么办?有人可以帮帮我吗?

Hi,

I have navigarionmaenu control on master page. This master page is applied to some pages.(Ex.Add.aspx,login.aspx)

Now I need to disable some child items of that navigationmenu control on add.aspx.
How can I do it ? Can someone please help me ?

推荐答案

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        var menu = Master.FindControl("NavigationMenu");
        if(menu != null)
        {
            // Here we do explicit convert for accessing to Menu properties
            // And in "Items" we specify Index of item that we want enable/disable
            ((System.Web.UI.WebControls.Menu)menu).Items[5].Enabled = false;
        }
    }
}


这篇关于如何禁用导航菜单控件的子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:45
查看更多