I need help with Master page - I am working on Header and Side lay out.

L

Learner

Hello,
Here is a little bit of what I am working ...

I have selected Header and Side lay out for my Master Page. All my
links go on the Side and the content on to the right pane. I have no
problem dealing wiht ContentPlaceHolder and the content pages. I also
have created a log in screen using Loin control and this works pretty
well too.

But my problem and where I need help is I need to be able to hide the
site links on the Side pane when the user requested our site. Its
perfectly brings up the Login page if the user is not authenticated but
I dont' know how do I hide the links on the Side when the Login screen
shows up. May be I need to handle the events to hide the links on the
Side pane but no clue how do I do it and what evets when the Login page
appears.


I have a screen shot of my Login page in the Master Page and for better
understanding I can send it over if needed.

Please help.

Thanks in advance,
-L
 
R

Robbe Morris [C# MVP]

There are a ton of ways to skin a cat. You could
always overwrite the contents of your place holder
that holds the links with an empty space when
certain pages load or some condition is met.

You can reference the place holders in
the master page from within any page that
uses them...
 
L

Learner

Hello Rob,
Thank you for the quick reply. Yes your second paragraph helped me to
establish the fact that we can control the Master page display from any
of its content pages.

Here is what I have done:

I have put the all the links in a contentPlaceHolder and named it
LINKS.

And in the Login.aspx content page I refered the above LINKS
contentPlaceHolder and mentioned nothing in there and there you go it
doesn't display the links now :)

Here is my Login.aspx content page html code

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="MainLogin.aspx.vb"
Inherits="UnSecured_MainLogin" title="Untitled Page" %>
<asp:Content ID="linksContent" ContentPlaceHolderID="LINKS"
runat="server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:Login ID="Login1" runat="server"
CreateUserUrl="~/UnSecured/CreateNewAcct.aspx">
</asp:Login>
</asp:Content>

as you the LINKS contentPlaceHolder is empty. So when ever this
Login.aspx appears my links won't display.

Hope the way I handled it is the correct way. If not please advise how
do I do it right.


I also tried doing it from the codebehind page of the Master page as
below

Protected Sub form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles form1.Load
If ContentPlaceHolder1.Page Is "MainLogin.aspx" Then
_lnkNewVehicle.Visible = False
_lnkReturnedVehicles.Visible = False
End If
End Sub

But it doesn't work and the way I have written the code is wrong. I
know that but I don't know how to handle it in the code behind page.

If you have couple of mins please help me how to handle it in the code
behind page and it helps me to understand to better handle the Master
page event in future.

Thanks for the help,
-L
 
R

Robbe Morris [C# MVP]

You will most likely need to run this code in the PreInit event of
the page.

C# syntax

protected void Page_PreInit(object sender, EventArgs e)
 
E

Erik Funkenbusch

But my problem and where I need help is I need to be able to hide the
site links on the Side pane when the user requested our site.

I assume you want to hide the links when the user is not logged in,
correct?

If so, simply add this code to the page_load even of the master page
(assuming vb):

If Not User.Identity.IsAuthenticated then
links.visible = False
End IF

You'll need to name the div (or whatever element) your links are contained
in to ID="links" and add a runat="server".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top