Click to See Complete Forum and Search --> : Is a 'namespace' but used like a 'type'


ttbarnes
08-06-2010, 07:12 AM
Hi guys,

I am writing some code behind, but struggaling to find a solution to this error. Would be very happy if someone could help me with this.

I have copied all of the code below, here is the highlighted problem:

*Part of Default.aspx.cs*
On the third of text, master_page brings the error "Is a namespace but used like a type'

private master_page MasterPage
{
get
{
return this.Master as master_page;
}
}

--------------------

*Final issue with Default.aspx.cs*
Second line of text - SitePage does not exist in the namespace Fiona_Ross.masterpage (are you missing an assembly reference?)

protected override void OnInit(EventArgs e)
{
MasterPage.CurrentPage = master_page.SitePage.Home;
base.OnInit(e);
}

---------------------

Here is the full Default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Fiona_Ross
{
public partial class Default : System.Web.UI.Page
{
private master_page MasterPage
{
get
{
return this.Master as master_page;
}
}

protected override void OnInit(EventArgs e)
{
MasterPage.CurrentPage = master_page.SitePage.Home;
base.OnInit(e);
}
}
}

----------------
Full master_page.Master.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Fiona_Ross.master_page
{
public partial class master_page : System.Web.UI.MasterPage
{
public SitePage CurrentPage { get; set; }

protected override void OnInit(EventArgs e)
{
CurrentPage = SitePage.Default;
base.OnInit(e);
}

protected void Page_Load(object sender, EventArgs e)
{
RenderNav();
}

private void RenderNav()
{
switch (CurrentPage)
{
case SitePage.Default:
// do nothing
break;
case SitePage.Home:
htm_home.Attributes["class"] = "on";
break;
case SitePage.Info:
htm_info.Attributes["class"] = "on";
break;
case SitePage.Contact:
htm_contact.Attributes["class"] = "on";
break;
default:
break;
}
}

public enum SitePage
{
Default,
Home,
Info,
Albums,
Photos,
Influences,
Contact
}
}
}

scousesheriff
08-11-2010, 08:15 AM
Hi

Perhaps it is something to do with

namespace Fiona_Ross.master_page


should it not just be

namespace Fiona_Ross

ttbarnes
09-05-2010, 04:39 PM
Thank you for the help Sheriff. I have now fixed the build! Happy days!

Best,

Tony