views:

204

answers:

3

Hi,

I am using a master page with a dynamic menu bar across the page. If the user has requested a redirect back to the login (home) page, I don't want to log them out but I do want to hide the menu bar. Currently I am using whether the user is authenticated to control if the menu bar is visible or not. Basically, I want to always hide the menu bar when on the login page. The menu is rendered prior to the page itself so I need to be able to read the redirect request to see if the login page is the destination. I tried a Response.RedirectLocation field but that seems to be null.

How can I determine what the redirect request is?

Thank you, James

A: 

I think your making this more complicated that it needs to be.

If your using master pages, just expose a public function in your master page that your content page can call and hide your menu. So in your login page you will always call the master pages hide menu function.

Here is a link to an MSDN article explaining how to expose the Master Page:

http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx

EDIT: You need to name you MasterPage's class something like MyMasterPage. Then make sure your inherits property in your Master's aspx page is correct:

Inherits="Your.Name.Space.MyMasterPage"

Then in your content page you should be to just add the following:

<%@ MasterType TypeName="Your.Name.Space.MyMasterPage" %>

Lastly you can access anything in your master page now since you have already defined it's type by:

Master.CallYourFunction();

That should get you working if you follow these steps.

Kelsey
That sounds reasonable, I will try this. Thank you
James
I was able to define the public Sub on the master page but I get not defined from the logic page. The login page does reference the master in the ASPX. What am I doing wrong?
James
If your masterpage is called 'MyMasterPage', you will have to do this on the login page: ((MyMasterPage)Master).HideMenuFunction().
Jan Jongboom
Ahhh, very nice! Thanks...
James
Dang... Syntax error. my master is defined<%@ Master Language="VB" CodeFile="MasterPage.master.vbv" Inherits="MasterPage" %>I coded ((MasterPage)Master.HideMenuBar()
James
I have updated my answer to give you a step by step.
Kelsey
Thank you Kelsey...
James
A: 

Make the redirect send the original url as a URL parameter like

&origurl=http://www.domain.com/original_page
lod3n
A: 

If you just wana hide Menu bar on login page then it wont be difficult. What you can do is you put Manu bar inside ContentPlaceHolder in Mater Page. And on your login page you can just add blank Content which will override Menu ContentPlaceholder from Master page.

<asp:Content ID="Content2" ContentPlaceHolderID="MenuContent" Runat="Server">

Here is declarative syntax on Mater page

<asp:ContentPlaceHolder id="MenuContent" runat="server"> Your Menu goes here    </asp:ContentPlaceHolder>

Now on other pages you do no have to override default content which is showing Menu from Mater page where you need to display Menu.

You can read more about overriding Mater Page's default content over Here.

Neil