本文介绍了我该如何解决错误“System.Web.UI.MasterPage'不包含一个定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个母版页和内容页。在我的本地机器这个code工作,但一旦我上传到服务器,我得到了以下错误:

I have two master pages and a content page. On my local machine this code works, but once I uploaded to the server I got the following error:

编译错误
说明:该请求提供服务所需资源的编译过程中出现错误。请检查下列特定错误详细信息并适当地修改源$ C ​​$ C。

Compilation ErrorDescription: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

编译器错误信息:CS1061:'System.Web.UI.MasterPage'不包含'DivWidth',没有扩展方法的定义DivWidth接受式的第一个参数System.Web.UI.MasterPage可能找到(是否缺少using指令或程序集引用?)

Compiler Error Message: CS1061: 'System.Web.UI.MasterPage' does not contain a definition for 'DivWidth' and no extension method 'DivWidth' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?)

源错误:

84号线:结果
85号线:结果
86号线:this.Master.Master.DivWidth = 955;
第87行:SimpleElementCollection restrictedIds =新SimpleElementCollection();
88号线:restrictedIds.Add(新SimpleElement(priceModifierPriceTypeId));

Line 84:
Line 85:
Line 86: this.Master.Master.DivWidth = 955;Line 87: SimpleElementCollection restrictedIds = new SimpleElementCollection();Line 88: restrictedIds.Add(new SimpleElement(priceModifierPriceTypeId));

源文件:C:\\的Inetpub \\测试网站\\店\\ Default.aspx.cs行:86

Source File: c:\Inetpub\testsite\shop\Default.aspx.cs Line: 86

母版基础cocde:

public partial class global : System.Web.UI.MasterPage
{
public int DivWidth { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
            SetBodyClass();
          if (DivWidth < 1)
        {
            DivWidth = 768;
        }
    }

母版基础ASPX:

Base Masterpage aspx:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="global.master.cs" Inherits="global" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
<head id="Head1" runat="server" dir="ltr" lang="en-us" profile="http://dublincore.org/documents/dcq-html/">
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>page title</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <meta http-equiv="content-type" content="en-US" />
  <meta http-equiv="content-language" content="en-us" />

  <link rel="Bookmark" href="#content" title="Page Content" type="text/html" />
  <link rel="Bookmark" href="#primary-navigation" title="Site Navigation" type="text/html" />

  <link href="css/screen/global.css" rel="stylesheet" type="text/css" media="screen"  />
<link href="css/print/print.css" rel="stylesheet" type="text/css" media="print" />


<script src="<%=ResolveUrl("~/javascript/jquery-1.2.6.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveUrl("~/javascript/jquery.clearonfocus.js")%>" type="text/javascript"></script>
<script src="<%=ResolveUrl("~/javascript/modalControl.js")%>" type="text/javascript"></script>
<asp:ContentPlaceHolder ID="headPlaceholder" runat="server" />
  <!--[if IE]><link href="css/screen/ie/ie.css" rel="stylesheet" type="text/css" media="screen"  /><![endif]-->
  <!--[if IE 6]><link href="css/screen/ie/ie-6.css" rel="stylesheet" type="text/css" media="screen"  /><![endif]-->

]
</head>
<body id="Body" runat="server">
<div id="main">
        <div id="main-inner">
            <div id="content" style="width:<%=DivWidth%>px;"><div id="content-top"></div><div class="content-inner"><asp:ContentPlaceHolder ID="contentPlaceHolder" runat="server" /><asp:ContentPlaceHolder ID="BelowLeftRightMainContent" runat="server" /></div> </div>

</body>
</html>

二母版页:

<%@ Master Language="C#" MasterPageFile="~/global.master" AutoEventWireup="false" CodeFile="shopFalcon.master.cs" Inherits="shopFalcon" %>
<%@ Register TagPrefix="FALCON" TagName="FeatureProducts" Src="~/FalconShopRightHand.ascx" %>
<%@ Register TagPrefix="FALCON" TagName="ProductSearch" Src="~/FalconProductSearch.ascx" %>
<%@ Register TagPrefix="FALCON" TagName="AbuseText" Src="~/FalconAbuseLinkDisplay.ascx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headPlaceholder" Runat="Server">
</asp:Content>

在没有任何概念的背后空code中的code后面

nothing in the code behind cept empty code behind

我的内容页:

<%@ Page Language="C#" MasterPageFile="~/shop.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="shopFalcon_Default" Title="Shop Homepage" %>
<%@ MasterType VirtualPath="~/shop.master"%>


<asp:Content ID="Content7" ContentPlaceHolderID="leftColPlaceHolder" Runat="Server">
<asp:Image ID="Image1" runat="server" ImageAlign="Right" ImageUrl="~/images/Free+Shipping+01.jpg" CssClass="img"/>
<h1>Shop Anytime, anywhere. </h1>

<div id="shopByBrandDiv">
    </asp:Content>

我的code背后:

My code behind:

  protected void Page_Load(object sender, EventArgs e)
        {


            this.Master.Master.DivWidth = 955;
    }

这再次使用内置的Web服务器,但delpoying到生产服务器上运行IIS6我得到这个错误上述工作在Visual Studio中。

Again this works in Visual Studio using the built in web server but delpoying to the production server running IIS6 I get that error stated above.

任何想法?

推荐答案

好吧,这里是东西,这个工作有时,然后当我添加其他财产或重新编译它会给我一个错误。事实证明,这是编译器的问题。为了解决这个问题,我不得不创建的根目录下APP_ code目录,并提出了类。当我得到的错误,告诉我​​没有定义DivWidth,我简单的做在我创建了一个类code修改和站点按正确的顺序编译。它打开了与MS,谁是不是非常有帮助,我找到这种解决方法的情况。希望这可以帮助别人谁运行到这个奇怪的问题。

Ok, here is the thing, this works sometimes and then when I add another property or recompile it would give me an error. it turns out it is compiler issue. To get around the issue, I had to create a App_Code directory under the root and made a class. When I get the error telling me there is no DivWidth defined, I simple make a code change in the class I created and the site compiles in the proper order. It took opening a case with MS, who was not very helpful, for me to find this workaround. Hope this helps someone else who runs into this strange issue.

这篇关于我该如何解决错误“System.Web.UI.MasterPage'不包含一个定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 01:30