Search code examples
asp.netmaster-pages

Master page gives error


I am using VS2008 for ASP.NET apps.

My Solution Explorer has hierarchy like this:

enter image description here

The start-up page, Default.aspx, displays a Login form. When I press Login button, another Page with the name, selectCompany, should open. selectCompany is a Web Content Form whose master page is Master1.Master. But it is not opening, instead I am getting this error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not load type 'FlexStock.Forms.master1'.

    Source Error:

    Line 1:  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="~/Forms/selectCompany.aspx" Inherits="FlexStock.Forms.master1" %>
    Line 2:  
    Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Source File: /Forms/master1.Master    Line: 1 

The first line of Master1.master is like this:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="master1.master.cs" Inherits="FlexStock.Forms.master1" %>

And the first line of Web Content Form, selectCompany.aspx, is like this:

<%@ Page Title="" Language="C#" MasterPageFile="~/Forms/master1.Master" AutoEventWireup="true" CodeBehind="selectCompany.aspx.cs" Inherits="FlexStock.Forms.selectCompany" %>

I am not following where is the problem.


Solution

  • Make sure that the class-name stated in the Inhertis-part of your page-directive matches the name of the class in your code-behind file.

    Master1.master:

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="master1.master.cs" Inherits="FlexStock.Forms.master1" %>
    

    Master1.Master.cs:

    namespace FlexStock.Forms {
        public class master1 {
            /* ... */