Master page gives error

一个人想着一个人 提交于 2019-12-11 03:39:51

问题


I am using VS2008 for ASP.NET apps.

My Solution Explorer has hierarchy like this:

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.


回答1:


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 {
        /* ... */



回答2:


Have you built your project w/o any errors/warning?

Error says that its unable to find code-behind class FlexStock.Forms.master1 so issue will be likely in master1.Master.cs or designer.cs - where you may have changed the namespace or class name w/o making the same change in markup. Or there is some compilation error and VS is unable to generate the assembly (or unable to put it in bin folder)




回答3:


If you can see the bin folder in Explorer, but not in VS, try "Including" it in your project.

Maybe drag the folder into Solution Explorer, and then right-click it and Include it.



来源:https://stackoverflow.com/questions/5828968/master-page-gives-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!