承接MOSS各种工作流开发 联系人:王先生.电话:18618405729QQ:252385878 QQ群:41696750 MSN:wanghao-3@hotmail.com

导航

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 onclick=\"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要简单的多~~~~

- - ||

 

posted on 2010-08-23 23:45  A A  阅读(713)  评论(0编辑  收藏  举报