如何在asp.net中隐藏子菜单 [英] How to hide sub menu in asp.net

查看:109
本文介绍了如何在asp.net中隐藏子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的前端菜单如下:



< pre lang =xml> < asp:菜单 ID = Menu1 宽度 = 100% 方向 = 水平 runat = server < span class =code-attribute> BackColor = #F7F6F3

< span class =code-attribute> DynamicHorizo​​ntalOffset = 2 字体粗体 = 字体名称 = Verdana

< span class =code-attribute> 字体大小 = 0.8 em ForeColor = #7C6F57 StaticSubMenuInde​​nt = 10px >
< StaticSelectedStyle BackColor = #5D7B9D / >
< StaticMenuItemStyle Horizo​​ntalPadding = 5px < span class =code-attribute> VerticalPadding = 2px / >
< DynamicHoverStyle BackColor = #7C6F57 < span class =code-attribute> ForeColor = 白色 / >
< DynamicMenuStyle BackColor = #F7F6F3 / >
< DynamicSelectedStyle BackColor = #5D7B9D < span class =code-attribute>
/ >
< DynamicMenuItemStyle Horizo​​ntalPadding = 5px VerticalPadding = 2px / >
< StaticHoverStyle BackColor = #7C6F57 ForeColor = 白色 / >
< 项目 >
< < span class =code-leadattribute> asp:MenuItem NavigateUrl = 〜/ TeamLeader / Home.aspx 文本 = 主页 = 主页 >
< / asp:MenuItem >
< asp:MenuItem < span class =code-attribute>文字 = 出勤报告 = 报告 >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / NewAttendanceReport.aspx

< span class =code-attribute> 文字 = 出勤报告 = 出席报告 > < / asp:MenuItem >
< asp: MenuItem NavigateUrl = 〜/ TeamLeader / LateComer.aspx 文字 = 即将到来的报告

< span class =code-attribute> = 已故的Comer报告 > < / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / DailMovementLog.aspx

< span class =code-attribute> 文字 = 每日移动日志报告 = < span class =code-keyword>每日移动日志报告 >
< / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / MeetingReport.aspx 文字 = 官方会议报告

= Officia lMeeting > < / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / LunchReport.aspx 文本 = 午餐报告

< span class =code-attribute> = 午餐报告 > ; < / asp:MenuItem > ;
< / asp:MenuItem >
< < span class =code-leadattribute> asp:MenuItem 文本 = 保留报告 = 保留报告 >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / LeaveReport.aspx 文本 = 保留报告

< span class =code-attribute> = 保留报告 > < / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / AllotedLeave.aspx

文字 = 分配的休假报告 = 分配的休假报告 > < / asp:MenuItem >
< asp: MenuItem NavigateUrl = 〜/ TeamLeader / ApprovalReport.aspx

文字 = 已批准/已拒登的离开报告

= 已批准/已拒登的报告 > < / asp:MenuItem >
< / asp:MenuItem >
< asp:MenuItem < span class =code-attribute>文本 = 员工报告 = 员工报告 >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / LeaveReportofEmployee.aspx

< span class =code-attribute> 文字 = 员工休假报告 Value = E mployee离开报告 > < / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / AvailableLeaveReport.aspx

文字 = 可用的休假报告 = 可用的休假报告 > < / asp:MenuItem >
< / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / ChangePassword.aspx 文本 = 更改密码

< span class =code-attribute> = 更改Passowrd > < / asp:MenuItem >
< asp:MenuItem NavigateUrl = 〜/ TeamLeader / Logoutt.aspx 文字 = 退出 = 退出 >
< / asp:MenuItem >









现在我想隐藏来自代码的一些子菜单。



请让我知道如何解决这个问题。

解决方案

你走了。



如何启用,以编程方式禁用菜单 [ ^ ]



免费附件



ASP。 NET菜单示例 [ ^ ](大约35个关于菜单的例子控制)


大家好

菜单

mnu.Items [1] .Enabled = false;



子菜单

mnu.Items [1] .ChildItems [0] .Enabled = false;


Hi all,

I have a menu as in front end as below:

<asp:Menu ID="Menu1" Width="100%" Orientation="Horizontal" runat="server" BackColor="#F7F6F3"

                            DynamicHorizontalOffset="2" Font-Bold="True" Font-Names="Verdana"

                            Font-Size="0.8em" ForeColor="#7C6F57" StaticSubMenuIndent="10px">
        <StaticSelectedStyle BackColor="#5D7B9D" />
        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
        <DynamicMenuStyle BackColor="#F7F6F3" />
        <DynamicSelectedStyle BackColor="#5D7B9D" />
        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
        <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
        <Items>
            <asp:MenuItem NavigateUrl="~/TeamLeader/Home.aspx" Text="Home" Value="Home">
            </asp:MenuItem>
            <asp:MenuItem Text="Attendance Report" Value="Reports">
                <asp:MenuItem NavigateUrl="~/TeamLeader/NewAttendanceReport.aspx"

                    Text="Attendance Report" Value="Attendance Report"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/LateComer.aspx" Text="Late Coming Report"

                    Value="Late Comer Report"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/DailMovementLog.aspx"

                    Text="Daily Movement Log Report" Value="Daily Movement Log Report">
                </asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/MeetingReport.aspx" Text="Official Meeting Report"

                    Value="Officia lMeeting"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/LunchReport.aspx" Text="Lunch Report"

                    Value="Lunch Report"></asp:MenuItem>
            </asp:MenuItem>
            <asp:MenuItem Text="Leave Reports" Value="Leave Reports">
                <asp:MenuItem NavigateUrl="~/TeamLeader/LeaveReport.aspx" Text="Leave Report"

                    Value="Leave Report"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/AllotedLeave.aspx"

                    Text="Allotted Leave Report" Value="Allotted Leave Report"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/ApprovalReport.aspx"

                    Text="Approved/Disapproved Leave Report"

                    Value="Approved/Disapproved Leave Report"></asp:MenuItem>
            </asp:MenuItem>
            <asp:MenuItem Text="Employee Report" Value="Employee Report">
                <asp:MenuItem NavigateUrl="~/TeamLeader/LeaveReportofEmployee.aspx"

                    Text="Employee Leave Report" Value="Employee Leave Report"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/TeamLeader/AvailableLeaveReport.aspx"

                    Text="Available Leave Report" Value="Available Leave Report"></asp:MenuItem>
            </asp:MenuItem>
            <asp:MenuItem NavigateUrl="~/TeamLeader/ChangePassword.aspx" Text="Change Password"

                Value="Change Passowrd"></asp:MenuItem>
            <asp:MenuItem NavigateUrl="~/TeamLeader/Logoutt.aspx" Text="Logout" Value="Logout">
            </asp:MenuItem>





Now I want to hide some sub-menus from code behind .

Please let me know how to solve this problem.

解决方案

Here you go.

How to enable, disable Menu programmatically[^]

Free attachment

ASP.NET Menu Examples[^](Around 35 examples about Menu control)


hi all
for menu
mnu.Items[1].Enabled = false;

for submenu
mnu.Items[1].ChildItems[0].Enabled = false;


这篇关于如何在asp.net中隐藏子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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