【问题标题】:How to configure MasterPage to Inherit class file如何配置 MasterPage 以继承类文件
【发布时间】:2014-07-04 13:12:36
【问题描述】:

我有一个需要从存储在“App_Web_yht1mma2”文件夹中的类 (MasterPage2.cs) 继承的母版页。

在母版页中,我将代码设置为:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="MasterPage2,App_Web_yht1mma2" %>

当我调试此页面时,我收到以下错误:

解析器错误 说明:解析服务此请求所需的资源时出错。请查看以下特定的解析错误详细信息并适当修改您的源文件。

Parser Error Message: Could not load the assembly 'App_Web_yht1mma2'. Make sure that it is compiled before accessing the page.

Source Error:

Line 1:  <%@ Master Language="C#" AutoEventWireup="true" Inherits="MasterPage2,App_Web_yht1mma2" %>
Line 2:
Line 3:

Source File: /MasterPage.master    Line: 1

请告诉我如何纠正这个错误。

【问题讨论】:

  • 构建解决方案,修复编译错误。
  • 谢谢...错误表明它无法加载程序集。
  • 您是否构建了项目并检查了编译器错误?
  • 是的,我做到了,除了警告之外,我仍然收到此错误“解析器错误消息:无法加载程序集 'App_Web_yht1mma2'。请确保在访问页面之前对其进行编译。”
  • 你得到的解析器错误是最终结果。您需要修复根本原因,以便您的 App_Web_yht1mma2 编译。为此,您需要修复编译时错误和警告。

标签: c# master-pages


【解决方案1】:

感谢您的帮助,但我设法通过朋友的帮助解决了这个问题。

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage2" %>

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MainMasterPageWeb.Master.cs"
Inherits="App_Web_yht1mma2.MasterPage2" %>

这两种方法都是可能的解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-19
    • 2017-08-28
    • 1970-01-01
    • 2011-12-26
    相关资源
    最近更新 更多