tags:

views:

208

answers:

2

I have a masterpage that I am reusing to create a new project. It works perfectly in project A. However, in project B I am getting a compile error saying the control does not exist in the current context. It baffles me. On the aspx page the control looks like:

<asp:Menu
     ID="Menu1"
     Orientation="Horizontal" 
     runat="server"
     Font-Bold="true"
     ForeColor="#9B301C"
     CssClass="noAunderline" 
     DynamicHoverStyle-BackColor="#ffff00"
     DynamicHoverStyle-Font-Bold="false"
     DynamicMenuItemStyle-Font-Bold="false" DynamicHoverStyle-Font-Underline="false"
     StaticHoverStyle-BackColor="#ffff00" 
     StaticEnableDefaultPopOutImage="true"
     DynamicHoverStyle-Width="200"
     DynamicEnableDefaultPopOutImage="true" 
     Target="_top"
     onmenuitemclick="Menu1_MenuItemClick">

<StaticMenuStyle
    BackColor="#ffffff"
    BorderStyle="None"
    BorderColor=""
    BorderWidth="0"
    Width="200"
    CssClass="noAunderline" />

<DynamicMenuStyle
    BackColor="#ffffff" 
    BorderStyle="Solid" 
    BorderColor="#aaaaaa" 
    BorderWidth="1"
    Font-Underline="false"
    Width="200"
    CssClass="noAunderline" />
</asp:Menu>

And on the code behind I have:

private MenuItem MenuAddRootItem(string NavName, string value, string imageURL, string NavLink, string target)
{
    MenuItem MasterItem = new MenuItem(NavName, value, imageURL, NavLink, target);
    Menu1.Items.Add(MasterItem);
    return MasterItem;
}

My colleagues suggest battling the same issue before, and the only solution found thus far is to create a new project and copy the code over. I would prefer to find a more definitive solution. Anyone else seen this issue?

Thanks!

A: 

ok it seems that deleting the master page out of the project and then add a new masterpage in visual studio and copying the code inside the skeleton did the trick. I'm thinking the designer.cs file wasn't properly ported into the project.

A: 

Yep, its usually a designer.cs problem - Control's field name isn't declared there.

Beresta