SharePoint Development-Custom page (Error page, logout page)

Source: Internet
Author: User

This article describes how to customize the native page of SharePoint, which is simple, in a word, "make a page, write a code." ”

Create a SharePoint empty solution, add the Layouts Mapping folder, add the paging file error.aspx, and signout.aspx.

Error.aspx

[HTML]View Plaincopyprint?
  1. <%@ Assembly name="$SharePoint. project.assemblyfullname$"%>
  2. <%@ Import namespace="Microsoft.SharePoint.ApplicationPages"%>
  3. <%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls"
  4. assembly="Microsoft.SharePoint, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c"% >
  5. <%@ register tagprefix=" Utilities " namespace=" Microsoft.SharePoint.Utilities " assembly=" microsoft.sharepoint, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c "  %>  
  6. <%@ Register tagprefix="asp" namespace= "System.Web.UI" assembly= "System.Web.Extensions, version=3.5.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "%>
  7. <%@ Import namespace="microsoft.sharepoint"%>
  8. <%@ Assembly name="Microsoft.Web.CommandUI, version=14.0.0.0, Culture=neutral, publickeytoken= 71e9bce111e9429c "%>
  9. <%@ page language="C #" autoeventwireup="true" codebehind="Error.aspx.cs" inherits= "Custompages.error"
  10. dynamicmasterpagefile="~masterurl/default.master"%>
  11. <asp:content id="Pagehead" contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
  12. </asp:content>
  13. <asp:content id="Main" contentplaceholderid="PlaceHolderMain" runat="Server" >
  14. An error has occurred, please contact the Administrator
  15. <!--custom error page, write code on this page--
  16. </asp:content>
  17. <asp:content id="pagetitle" contentplaceholderid="Placeholderpagetitle" runat=" Server ">
  18. Application Page
  19. </asp:content>
  20. <asp:content id="Pagetitleintitlearea" contentplaceholderid=" Placeholderpagetitleintitlearea "
  21. runat="Server">
  22. My Apps page
  23. </asp:content>

Signout.aspx

[HTML]View Plaincopyprint?
  1. <%@ Assembly name="$SharePoint. project.assemblyfullname$"%>
  2. <%@ Import namespace="Microsoft.SharePoint.ApplicationPages"%>
  3. <%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls"
  4. assembly="Microsoft.SharePoint, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c"% >
  5. <%@ register tagprefix=" Utilities " namespace=" Microsoft.SharePoint.Utilities " assembly=" microsoft.sharepoint, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c "  %>  
  6. <%@ Register tagprefix="asp" namespace= "System.Web.UI" assembly= "System.Web.Extensions, version=3.5.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "%>
  7. <%@ Import namespace="microsoft.sharepoint"%>
  8. <%@ Assembly name="Microsoft.Web.CommandUI, version=14.0.0.0, Culture=neutral, publickeytoken= 71e9bce111e9429c "%>
  9. <%@ page language="C #" autoeventwireup="true" codebehind="Signout.aspx.cs" inherits="Custompages.signout"
  10. masterpagefile="~/_layouts/simple.master"%>
  11. <asp:content contentplaceholderid="Placeholderpagetitle" runat= "server">
  12. <sharepoint:encodedliteral runat="Server" text="<% $Resources: Wss,signout_ Pagetitle%> "
  13. encodemethod=' HtmlEncode ' />
  14. </asp:content>
  15. <asp:content contentplaceholderid="Placeholderpagetitleintitlearea" runat="Server " >
  16. <sharepoint:encodedliteral runat="Server" text="<% $Resources: Wss,signout_pagetitle %> "
  17. encodemethod=' HtmlEncode ' />
  18. </asp:content>
  19. <asp:content contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
  20. <script type="Text/javascript">
  21. function ULSd63 () {var o = new Object; o.ulsteamname = "Microsoft SharePoint Foundation";  o.ulsfilename = "signout.aspx"; return o;}
  22. function _spbodyonload () {
  23. ULSD63:;
  24. Window.close ();
  25. }
  26. </Script>
  27. </asp:content>
  28. <asp:content contentplaceholderid="PlaceHolderMain" runat= "server">
  29. <asp:label id="lbpagedescription" text="<% $Resources: Wss,signout_ Pagedescription%> "
  30. runat="Server" />
  31. </asp:content>

The benefit of customizing the page is that you can handle some of the actions that you actually need.

Then add feature, activate and deactivate events

[CSharp]View Plaincopyprint?
  1. Public override void FeatureActivated (spfeaturereceiverproperties properties)
  2. {
  3. Spwebapplication webApp = properties.  Feature.parent as spwebapplication;
  4. if (null! = webApp)
  5. {
  6. Webapp.updatemappedpage (SPWebApplication.SPCustomPage.Error, "/_layouts/sp_mip/custompages/error.aspx");
  7. Webapp.updatemappedpage (SPWebApplication.SPCustomPage.Signout, "/_layouts/sp_mip/custompages/signout.aspx")  ;
  8. Webapp.update (true);
  9. }
  10. }
  11. public override void FeatureDeactivating (spfeaturereceiverproperties properties)
  12. {
  13. Spwebapplication webApp = properties.  Feature.parent as spwebapplication;
  14. if (null! = webApp)
  15. {
  16. Webapp.updatemappedpage (SPWebApplication.SPCustomPage.Error, null);
  17. Webapp.updatemappedpage (SPWebApplication.SPCustomPage.Signout, null);
  18. Webapp.update (true);
  19. }
  20. }

SharePoint Development-Custom page (Error page, logout page)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.