SharePoint開發,sharepoint

來源:互聯網
上載者:User

SharePoint開發,sharepoint

本文敘述如何自訂SharePoint的固有頁面,比較簡單,用一句話說就是“做個頁面,寫一句代碼。”

建立SharePoint空解決方案,添加Layouts對應檔夾,添加分頁檔error.aspx和signout.aspx。

error.aspx

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %><%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %><%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %><%@ Import Namespace="Microsoft.SharePoint" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="error.aspx.cs" Inherits="CustomPages.error"    DynamicMasterPageFile="~masterurl/default.master" %><asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"></asp:Content><asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">    出現錯誤,請聯絡管理員    <!--自訂錯誤頁面,在此頁面寫代碼--></asp:Content><asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">    應用程式頁</asp:Content><asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"    runat="server">    我的應用程式頁</asp:Content>
signout.aspx

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %><%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %><%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %><%@ Import Namespace="Microsoft.SharePoint" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="signout.aspx.cs" Inherits="CustomPages.signout"    MasterPageFile="~/_layouts/simple.master" %><asp:Content ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">    <SharePoint:EncodedLiteral runat="server" Text="<%$Resources:wss,signout_pagetitle%>"        EncodeMethod='HtmlEncode' /></asp:Content><asp:Content ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">    <SharePoint:EncodedLiteral runat="server" Text="<%$Resources:wss,signout_pagetitle%>"        EncodeMethod='HtmlEncode' /></asp:Content><asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">    <script type="text/javascript">        function ULSd63() { var o = new Object; o.ULSTeamName = "Microsoft SharePoint Foundation"; o.ULSFileName = "SignOut.aspx"; return o; }        function _spBodyOnLoad() {            ULSd63: ;            window.close();        }    </script></asp:Content><asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">    <asp:Label ID="lbPageDescription" Text="<%$Resources:wss,signout_pagedescription%>"        runat="server" /></asp:Content>
自訂頁面的好處是可以處理一些自己實際中需要的操作。

然後添加feature,啟用和取消啟用事件

public override void FeatureActivated(SPFeatureReceiverProperties properties)        {            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;            if (null != webApp)            {                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, "/_layouts/SP_MIP/CustomPages/error.aspx");                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Signout, "/_layouts/SP_MIP/CustomPages/signout.aspx");                webApp.Update(true);            }        }        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)        {            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;            if (null != webApp)            {                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, null);                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Signout, null);                webApp.Update(true);            }        }
核心就一句話

webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error,"/_layouts/SP_MIP/CustomPages/error.aspx");

有這些頁面可以自訂




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.