CSDN博客

img maseccc

如何创建自定义Sharepoint 应用程序页 (Creating an Application Page in Windows SharePoint Services 3.0)

发表于2009/1/12 12:26:00  1768人阅读

 应用程序页(也称作“_ layouts”页)存储在C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/LAYOUTS目录中。IIS中对应的虚拟目录为:_layouts.

 

应用程序页使用application.master母版页,并继承Microsoft.SharePoint.WebControls.LayoutsPageBase,此页面只有认证通过并有一定的授权的用户才能访问。

一个简单的应用程序页如下所示:

  1. <%@ Assembly Name="Microsoft.SharePoint,Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
  2. <%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"  
  3. Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>
  4. <%@ Import Namespace="Microsoft.SharePoint" %>
  5. <script runat="server">
  6.   protected override void OnLoad(EventArgs e) 
  7.   {
  8.         SPWeb web = SPContext.Current.Web ;
  9.         SPUser currentUser = web.CurrentUser;
  10.         lblUserName.Text = currentUser.Name;
  11.         lblUserLogin.Text = currentUser.LoginName;
  12.         lblUserEmail.Text = currentUser.Email;  
  13.   }
  14. </script>
  15. <asp:Content ID="Main" contentplaceholderid="PlaceHolderMain" runat="server">
  16.   <table border="1" cellpadding="4" cellspacing="0" style="font-size:12">
  17.     <tr>
  18.       <td>CurrentUserName:</td>
  19.       <td><asp:Label ID="lblUserName" runat="server" /></td>
  20.     </tr>
  21.     <tr>
  22.       <td>CurrentUserLogin:</td>
  23.       <td><asp:Label ID="lblUserLogin" runat="server" /></td>
  24.     </tr>
  25.     <tr>
  26.       <td>CurrentUserEmail:</td>
  27.       <td><asp:Label ID="lblUserEmail" runat="server" /></td>
  28.     </tr>
  29.   </table>
  30. </asp:Content>
  31. <asp:Content ID="PageTitle" runat="server"
  32.              contentplaceholderid="PlaceHolderPageTitle" >
  33.   Hello World
  34. </asp:Content>
  35. <asp:Content ID="PageTitleInTitleArea" runat="server"
  36.              contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
  37.   The Quintessential 'Hello World' Application Page
  38. </asp:Content>

另:_layout下的页面也可以不继承Sharepoint的类,

如:

 

  1. <%@ Page Language="C#" %>
  2. <%@ Assembly Name="Microsoft.SharePoint,Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
  3. <%@ Import Namespace="Microsoft.SharePoint" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <script runat="server">
  6.   protected override void OnLoad(EventArgs e) 
  7.   {
  8.         SPWeb web = SPContext.Current.Web ;
  9.         SPUser currentUser = web.CurrentUser;
  10.         lblUserName.Text = currentUser.Name;
  11.         lblUserLogin.Text = currentUser.LoginName;
  12.         lblUserEmail.Text = currentUser.Email;  
  13.   }
  14. </script>
  15. <html xmlns="http://www.w3.org/1999/xhtml" >
  16. <head runat="server">
  17.     <title>无标题页</title>
  18. </head>
  19. <body>
  20.     <form id="form1" runat="server">
  21.     <div>
  22.      <table border="1" cellpadding="4" cellspacing="0" style="font-size:12">
  23.     <tr>
  24.       <td>CurrentUserName:</td>
  25.       <td><asp:Label ID="lblUserName" runat="server" /></td>
  26.     </tr>
  27.     <tr>
  28.       <td>CurrentUserLogin:</td>
  29.       <td><asp:Label ID="lblUserLogin" runat="server" /></td>
  30.     </tr>
  31.     <tr>
  32.       <td>CurrentUserEmail:</td>
  33.       <td><asp:Label ID="lblUserEmail" runat="server" /></td>
  34.     </tr>
  35.   </table>
  36.     </div>
  37.     </form>
  38. </body>
  39. </html>

 

 

0 0

相关博文

我的热门文章

img
取 消
img