Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自定义Sharepoint应用程序中的页面继承_C#_Asp.net_Sharepoint - Fatal编程技术网

C# 自定义Sharepoint应用程序中的页面继承

C# 自定义Sharepoint应用程序中的页面继承,c#,asp.net,sharepoint,C#,Asp.net,Sharepoint,我在sharepoint服务器上的文件夹_layouts/sandbox中有一个default.aspx 其代码如下: using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using Syst

我在sharepoint服务器上的文件夹_layouts/sandbox中有一个default.aspx

其代码如下:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

using System.Web.Configuration;

namespace sandbox
{

    public partial class _Default : LayoutsAppPage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb web = SPContext.Current.Web;
            LabelTitle.Text = web.Title;

            if (Page.IsPostBack == false)
            {
                //Label1.Text = "Fahrenheit to Celsius:";
            }
        }

        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            try
            {
                this.MasterPageFile = SPContext.Current.Web.MasterUrl;
            }
            catch
            {
            }
        }



    }

}
它应该内置layoutsappage类,以便我可以使用它在“sandbox”应用程序的所有页面中执行OnPreInit函数。以下是在同一目录中布局sappage.aspx.cs的代码

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

using System.Web.Configuration;

namespace sandbox
{
    public class LayoutsAppPage : System.Web.UI.Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            try
            {
                this.MasterPageFile = SPContext.Current.Web.MasterUrl;
            }
            catch
            {
            }
        }
    }
}
我在运行页面时遇到以下错误

c:\Program Files\Common 文件\Microsoft共享\Web服务器 扩展\12\TEMPLATE\LAYOUTS\sandbox\Default.aspx.cs(20): 错误CS0246:类型或命名空间无效 无法找到名称“LayoutSappage” 发现(您是否缺少一个可用的 指令或组件参考?
在 System.Web.Compilation.AssemblyBuilder.Compile()

我注意到在“public partial class\u Default:layoutsappage”行中,layoutsappage并没有像基类那样变成浅蓝色。如果行为“public partial class\u Default:System.Web.UI.Page”,则页面可以正常加载。也许我声明的基页不正确

编辑:根据请求-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="sandbox._Default" MasterPageFile="~/_layouts/application.master" %>

<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages,Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="/_controltemplates/ButtonSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" Src="/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" Src="/_controltemplates/ToolBarButton.ascx" %>

如果程序集部署到GAC或使用公钥签名,则必须指定页面元素的继承属性才能使用完整类型和程序集名称,如以下所示:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_Default.aspx.cs" 
Inherits="CustomAssemblyNamespace.sandbox._Default, CustomAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a01d56a735c19c1"  %>


您是否也可以在标记页面的顶部发布所有指令?我已将所有指令添加到原始帖子的末尾,感谢您查看kbrimington。我可能正在抓紧稻草,因此我将仅作为注释发布。我总是在@Page指令的Inherits属性中使用类的程序集限定名。另外,再次检查项目中所有的.cs文件是否设置为编译。另外,请确保您使用的是Web应用程序项目,而不是Web站点。祝你好运对不起,您能解释一下assembley限定名的含义吗?我对asp.net/c还不太熟悉,在学习的过程中,我一直在努力解决很多问题。