does not contain a definition for context error in ASP .Net
I created a masterpage that uses another masterpage. I copied the first line that defines the code files, master page used etc. Then I got into this error on compilation:
does not contain a definition for context error
Also the page using the masterpage was throwing error.
I never seen an error like this before. After digging online and looking at the code realized I didn’t do something right.
<%@ Master Language=”C#” AutoEventWireup=”true” MasterPageFile=”~/MasterPageGeneric.master” CodeFile=”MasterPageManager.master.cs” Inherits=”MasterPageManager” %>
Since the new master page was inside a folder, and the parent masterpage was in root level, copying the first line was my source of error. I forgot to update the Inherts part accordingly. By default ASP .Net uses foldername_filename as the name of the class; and the Inherts attribute should be updated accordingly.
<%@ Master Language=”C#” AutoEventWireup=”true” MasterPageFile=”~/MasterPageGeneric.master” CodeFile=”MasterPageManager.master.cs” Inherits=“manager_MasterPageManager” %>
Now that I have updated that part, errors went away.










Leave your response!