4
votes

EDIT: The main problem seemed to be that I was just doing "Add Existing Item" from an old web site project into an ASP.NET Web Application project. This caused so much trouble I just started from scratch, except that instead of adding existing items, I added new Master Pages and aspx pages to the project then populated them. The same problem persists.

I have a legacy project that is just a standard web site. I've started a new project as a web application and have transplanted in all the pages I need. However, I'm receiving 100+ errors that are comprised mostly of slightly different permutations of the following:

  • 'System.Web.UI.MasterPage does not contain a definition for 'headerImage' (I get this in code-behind)
  • 'MasterPage' does not contain a definition for 'imgHeader' (also this is in code-behind)

Regarding the first error, it's as though the project is not comprehending that the master page is set. I set the master page at the top of each one of my aspx pages like:

<%@ page language="C#" masterpagefile="~/MasterPages/MasterPage.master" autoeventwireup="true" inherits="Equipment.aspx.cs" title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/MasterPage.master"  %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!-- some content -->
</asp:Content>

Also, I clearly expose a headerImage property in the ~/MasterPages/MasterPage.master code-behind:

   public partial class MasterPage : System.Web.UI.MasterPage
   {
      #region Properties

      private string _headerImage;
      public string headerImage
      {
         get
         {
            return _headerImage;
         }
         set
         {
            _headerImage = (string)value;
         }

      }

      // other stuff
   }

And yet VS is still looking for this property in the System.Web.UI.MasterPage base class!

I've already checked out this post and it didn't solve my problem.

Thoughts? All feedback is appreciated. Thanks guys.

3
where is the ext for this file "~/MasterPages/MasterPage.masterMethodMan
@DJKRAZE I'm new to VS ASP.NET. If you mean extension, it's just .master, and .cs for the code behind.kmarks2

3 Answers

3
votes

Good morning when you added the existing files to your new web application did you recreate them all from scratch or did you do a literal "Add Existing Item"? If so, then you should right click on each of the files and click the "Convert To Web Application" option.

2
votes

Check what is the namespace of this.Master. If it's System.Web.UI.MasterPage, try to rename your master page to a different name. This way you can isolate the problem.

0
votes

My answer is similar to that of @mreyeros - however, my designer file was present already - it was that Vs didn't recognise the partial nature of the none- designer class and thus link the 2 together.

The fix I used was to remove the files from the project and re-add them using add existing. I did this in bulk and the newly added files behaved correctly and the error went away.