【发布时间】:2010-09-13 11:52:32
【问题描述】:
我正在尝试使我的母版页与我的内容页一起使用,从而允许内容页访问母版页控件。我得到了错误:
解析器错误消息:'mastertype' 指令必须恰好有一个 属性:TypeName 或 VirtualPath
这是在线:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="viewProduct.aspx.cs" Inherits="AlphaPackSite.viewProduct"
MasterPageFile="MasterPages/Main.master"
title="Hi there!"
%>
<%@ MasterType TypeName="Main" VirtualPath="MasterPages/Main.master" %>
我的母版页是:
namespace AlphaPackSite
{
public partial class Main : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
我对命名空间有点困惑,所以可能弄错了,但现在我相信所有页面都在同一个命名空间中。
更新
当我把它变成:
<%@ MasterType VirtualPath="MasterPages/Main.master" %>
我不断收到错误:
Compiler Error Message: CS0030: Cannot convert type 'AlphaPackSite.Main' to 'ASP.masterpages_main_master'
Source Error:
Line 147: public new ASP.masterpages_main_master Master {
Line 148: get {
Line 149: return ((ASP.masterpages_main_master)(base.Master));
Line 150: }
Line 151: }
【问题讨论】:
标签: c# asp.net master-pages