SharePoint 页面库 使用footer

图片:

我们只需要在我们的page Content Type里面定义好我们的模板就可以

User Controls Code:

 

<%@ Control Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Administration" %>
<script runat="server">
    string stLastModifiedDate = string.Empty;
    string stLastModifiedBy = string.Empty;
    string stLastModifiedByMemberID = string.Empty;   
   
    string stTxt = string.Empty;
    public string FileName()
    {
        return System.Web.HttpContext.Current.Request.Url.AbsolutePath;
    }
    void Page_Load(object sender, EventArgs e)
    {
        string stPageName = FileName();
        using (SPSite RootSite = new SPSite(Page.Request.Url.ToString()))
        {
            using (SPWeb SiteCollection = RootSite.OpenWeb())
            {
                string stPath = RootSite.MakeFullUrl(stPageName);
                SPFile File = SiteCollection.GetFile(stPath);
                DateTime dateLastModifiedDate = File.TimeLastModified;
                stLastModifiedDate =
                  SiteCollection.RegionalSettings.TimeZone.UTCToLocalTime(
                  dateLastModifiedDate).ToString();
               
                SPUser ModifierUser = File.ModifiedBy;
                stLastModifiedBy = ModifierUser.Name.ToString();
                stLastModifiedByMemberID = ModifierUser.ID.ToString();
                stTxt = "Last modified by:<a οnclick=\"GoToLink(this);" +
                  "return false;\" href=\"../_layouts/userdisp." +
                 "aspx?ID=" + stLastModifiedByMemberID +
                 "\">" + stLastModifiedBy +
                 "</a>  " + stLastModifiedDate;
            }
        }
    }
</script>
<table class="pageFooter">
    <tr>
        <td>
            <%= stTxt %>
        </td>
    </tr>
</table>

CSS 文件:

<style type="text/css">
.pageFooter
{   font-family:Arial;
    font-size:10px;
    color:#4d4d4d;
    line-height: 12px;

}

.pageFooter A:link
{
    color:#8b9700;
}
</style>

 

使用的时候,只需要把这个用户控件插入到指定的地方,

方法:

 

注册:

<%@ Register TagPrefix="Flygare"
    TagName="PageFooter" src="~/_controltemplates/PageFooter.ascx" %>

在需要使用页脚的Content type 

插入

<Flygare:PageFooter id="PageFoot" runat="server" enableviewstate="true">
</Flygare:PageFooter>

 其实这种方法不是最好的,可是我们可以通过这种方法,举一反三,写一些很好的feature的东西

比如我们可以在用户控件里面写很多客户定制化的东西,然后在指定的地方插入。比写webpart要简单的多~~~~

- - ||

 

转载于:https://www.cnblogs.com/wanghao-3/archive/2010/08/23/1806866.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值