Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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" %>
Posted
Updated 25-Feb-16 23:00pm
Comments
[no name] 26-Feb-16 4:47am    
What is the HTML code for your menu?

Option1: Using Page.Master.FindControl()

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

Step2: Below need to present in your child/content page Page_Load()
C#
protected void Page_Load(object sender, EventArgs e)
{
	Control myControlMenu = Page.Master.FindControl("divTemp");
	if(myControlMenu != null)
	{
		myControlMenu.Visible = false;
	}
}

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.
 
Share this answer
 
Comments
Member 10376341 26-Feb-16 5:13am    
First option worked for me.
Thank you Manas Kumar, i appreciate your help.

Regards
Saiekrishna
[no name] 26-Feb-16 5:16am    
Welcome :)
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..
 
Share this answer
 
Comments
Member 10376341 26-Feb-16 5:01am    
Can you explain me briefly, i couldn't get result specified by you.
Manoj Sawant 26-Feb-16 5:11am    
your Login Page will contain only the Login Controls and nothing else, so create a master page A, where you can give your necessary look and feel for your login page, example the title for your project, Background Image or Color and any type of graphic. where as Create another Master Page B where you have a systematic look and feel, well organized menu tab and showing the user name who has logged in.
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.
 
Share this answer
 
Comments
Member 10376341 26-Feb-16 4:58am    
Am using ASP template. Nothing changed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900