SharePiont文档库使用页面代码方法一

  SharePiont文档库里面是可以使用Aspx页面的,可以使用Asp风格的代码添加Asp.net代码进行相关操作如下:

  
    
<% @ Page Language = " C# " %>
<% @ Import Namespace = " Microsoft.SharePoint " %>

<% @ Import Namespace = " Microsoft.SharePoint.WebControls " %>

< html xmlns:mso = " urn:schemas-microsoft-com:office:office " xmlns:msdt = " uuid:C2F41010-65B3-11d1-A29F-00AA00C14882 " >

< head id = " Head1 " runat = " server " >
< META name = " WebPartPageExpansion " content = " full " >
< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " >

< title > 页面信息跳转 </ title >

< script runat = " server " >

protected void Page_Load( object sender, EventArgs e)
{
SPUser struser
= SPContext.Current.Web.CurrentUser;
string UserEmail = struser.Email;
string UserName = struser.Name;
string userLoginName = struser.LoginName;
string strPama = string .Empty;
strPama
= " userName= " + System.Web.HttpUtility.UrlEncode(UserName) + " &userEmail= " + UserEmail;
this .Response.Redirect( " http://172.16.0.55:8051/index.aspx? " + strPama);
}

</ script >
</ head >

      但是这时候访问Aspx页面时就会提示如下错误:“此文件中不充许使用代码块”

  这是因为SharePoint页面安全性问题,可以在对应的站点下面的Web.config里面找到

  <PageParserPaths>

    <!-- 添加开始 -->

    <PageParserPath VirtualPath="/文档库路径名/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="false" />

    <!-- 添加结束 -->

  </PageParserPaths>

  “*”是表示这个路径名下面的所有文件都可以。

你可能感兴趣的:(sha)