如何在登录页面asp.net中禁用母版页菜单。 [英] How to disable master page menu in login page asp.net.

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

问题描述

大家好,



当天的问候!



我相信很多人都会问过很多时间,但我找不到其他更好的解决方案。



好​​吧,我试图从登录页面禁用母版页面菜单 ,所以没有用户可以查看菜单,除非他/她登录。



我在内置的ASP模板中使用。尝试从登录页面删除母版页衍生物,但它不起作用。



谢谢

Saiekrishna



我尝试过:



<%@ Page Title =登录Language =C#AutoEventWireup =trueCodeBehind =Login.aspx.cs Inherits =WebApplication8.Account.LoginAsync =true%>

Hello All,

Greetings for the day!

Am sure it has been asked many times, but i couldn't find the better solution else where.

Well, am trying to disable Master Page Menu from the Login Page, so that no user can view the menu's unless he/she logs in.

Am using in built ASP template. Tried deleting the master page derivatives from login page but it did not work.

Thanks
Saiekrishna

What I have tried:

<%@ Page Title="Log in" Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebApplication8.Account.Login" Async="true" %>

推荐答案



我建议你创建登录页面的主要母版页面和页面的不同母版页面,因此您无需在每个页面上启用和禁用控件..
Hi,
Well i recommend you to create a main master page for Login page and different Master page for pages, thus you need not enable and disable the controls on each and every page..


我们无法提供太多帮助而不知道你如何实现你的菜单或身份验证,但是你的菜单是一个控件(如果它还没有)然后在你的母版页的代码隐藏中,在页面加载事件中将菜单的Visibility属性设置为false如果用户未经过身份验证。
We can't give much help without knowing how you are implementing your menu or authentication, but make your menu a control (if it isn't already) then in the code-behind of your master page, in the page load event set the menu's Visibility property to "false" if the user is not authenticated.


Option1 :使用 Page.Master.FindControl()



Step1 :以下代码仅用于菜单的页面

Option1: Using Page.Master.FindControl()

Step1: Below code present in your mater page for menu only
<form id="form1" runat="server">
        <div id="divTemp" runat="server">
            Your menu here
        </div>
</form>	



Step2 :以下需要出现在您的孩子/内容页面Page_Load()


Step2: Below need to present in your child/content page Page_Load()

protected void Page_Load(object sender, EventArgs e)
{
	Control myControlMenu = Page.Master.FindControl("divTemp");
	if(myControlMenu != null)
	{
		myControlMenu.Visible = false;
	}
}



Option2 :创建两个母版页 - 一个(master1.master)用于登录页面,另一个其他页面的一个(master2.master)。您可以将 master1 用于帮助页面等页面,联系我们页面,因为在那些我们不需要实际菜单。



选择一个对你来说可行的。


Option2: Create two master pages - one(master1.master) for login page and another one(master2.master) for other pages. You can use master1 for pages like help page, contact us page because in those we don't need actual menus.

Choose one them which is feasible for you.


这篇关于如何在登录页面asp.net中禁用母版页菜单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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