SeanNij
asked on
BasePage properties sometimes there, sometimes not.
Hi All,
I have been searching like crazy but can't seem to get the answer I want.
I have a ASP.NET 2.0 project.
I inherit a BasePage called DefaultBasePage to check whether user is logged in.
Also uses properties in this page to check on my master page if I should display the menu or not.
I've got 2 pages here that are exactly the same with regards to this, but one of the pages gets the value from the base page and the other doesn't.
Here is my DefaultBasePage.cs
DefaultMaster.master.cs
Any ideas would be greatly appreciated as I am banging my head against the wall because of this,
Thanks in advance,
S
I have been searching like crazy but can't seem to get the answer I want.
I have a ASP.NET 2.0 project.
I inherit a BasePage called DefaultBasePage to check whether user is logged in.
Also uses properties in this page to check on my master page if I should display the menu or not.
I've got 2 pages here that are exactly the same with regards to this, but one of the pages gets the value from the base page and the other doesn't.
Here is my DefaultBasePage.cs
public class DefaultBasePage : System.Web.UI.Page
{
private bool bShowHeadersFooters;
private bool bNeedsToBeLoggedIn = true;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Session["ID"] == null
&& !Request.Url.ToString().Contains("login.aspx")
&& bNeedsToBeLoggedIn)
{
Response.Redirect(Application["URL"] + "login.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.ToString()));
}
}
public bool ShowHeadersAndFooters
{
get { return bShowHeadersFooters; }
set { bShowHeadersFooters = value; }
}
}
DefaultMaster.master.cs
if (Page is DefaultBasePage)
{
bShowHeadersAndFooters = ((DefaultBasePage)Page).ShowHeadersAndFooters;
if (Session["ID"] != null)
{
if (bShowHeadersAndFooters)
{
// Show Menu. Works sometimes and sometimes not.
}
}
}
Any ideas would be greatly appreciated as I am banging my head against the wall because of this,
Thanks in advance,
S
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi!
You're welcome! Any "reward" for this?
You're welcome! Any "reward" for this?
ASKER
@ghergu Close Request Pending. Points awarded to you. Will close auto on 02/04/2013 if no objections.
ASKER
First answer gave me an idea and created my own solution. Point still awarded to the person who gave me the idea.
Where are you setting your ShowHeadersAndFooters properties? By default it's false.
You must set them somewhere on your page.