转:http://blog.csdn.net/yl_99/article/details/7087897

方法一、使用SharePoint Designer配合enderingTemplate文件来定制MOSS/WSS表单页面

以通知列表(DispForm.aspx)为例,

系统默认的通知列表样式如下:

默认样式用于新闻发布的时候确实不符合中国人的习惯,下面我们要把它改成如下的样子:

  第一步--修改表单页面默认模板:用SPD打开要修改的页面(DispForm.aspx),找到ListFormWebPart,修改其TemplateName属性为CodeArt_NoticeTemplate,如下:

------------------------------------------------------------------------------------------

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">CodeArt_NoticeTemplate</TemplateName>

------------------------------------------------------------------------------------------

  第二步--编写新模板:将一下的内容保存到12TEMPLATECONTROLTEMPLATESCodeArt_NoticeTemplate.ascx文件中:CodeArt_NoticeTemplate.ascx

------------------------------------------------------------------------------------------

< %@ Control Language="C#" AutoEventWireup="false" %>

< %@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

< %@ Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

  Namespace="Microsoft.SharePoint.WebControls" %>

< SharePoint:RenderingTemplate ID="CodeArt_NoticeTemplate" runat="server">

  <Template>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td class="FormToolBar">

          <SharePoint:InformationBar ID="InformationBar1" runat="server" />

          <SharePoint:FormToolBar ID="FormToolBar1" runat="server" Visible="false" />

        </td>

      </tr>

    </table>

    <table width="95%" border="0" cellspacing="8" cellpadding="0">

      <tr>

        <td align="center" height="30px" class="title">

          <b>

            <SharePoint:FormField ID="FormField1" runat="server" FieldName="Title" />

          </b>

        </td>

      </tr>

      <tr>

        <td align="right">

          <SharePoint:CreatedModifiedInfo ID="CreatedModifiedInfo1" runat="server" />

        </td>

      </tr>

      <tr>

        <td height="1" align="center" class="seprow">

        </td>

      </tr>

      <tr>

        <td valign="top" class="content">

          <SharePoint:FormField ID="FormField2" runat="server" FieldName="Body" />

        </td>

      </tr>

      <tr>

        <td>

          <table border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td>

                &nbsp;&nbsp;</td>

              <td>

                <table border="0" cellspacing="0" cellpadding="0">

                  <SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows"

                    runat="server" />

                </table>

                <SharePoint:AttachmentUpload Visible="false" ID="AttachmentUpload1" runat="server" />

              </td>

            </tr>

          </table>

        </td>

      </tr>

      <tr>

        <td>

        </td>

      </tr>

      <tr>

        <td align="center">

          <table>

            <tr>

              <td>

                <SharePoint:GoBackButton ID="GoBackButton2" Visible="false"

                  runat="server" />

                <input type="button" value=' 返 回 ' onclick="javascript:CloseWindow();return false;" />

                <!--img src="/_wpresources/DisForm/b_close.gif" onclick="javascript:IsCloseWindow();return false;" width="122" height="25"-->

              </td>

            </tr>

          </table>

        </td>

      </tr>

      <tr>

        <td align="center">

          &nbsp;</td>

      </tr>

    </table>

    <script language="javascript">

function CloseWindow()

{

  if( window.opener != null )

  {

    self.close();

  }

  else

  {

    history.back(-1);

  }

}

    </script>

  </Template>

< /SharePoint:RenderingTemplate>

------------------------------------------------------------------------------------------

  第三步:重启IIS或应用程序池。

  哈哈,你可以刷新页面看效果了。

CodeArt_NoticeTemplate.ascx里面的内容重点关注以下标签:

------------------------------------------------------------------------------------------

<SharePoint:FormField ID="FormField1" runat="server" FieldName="Title" />

------------------------------------------------------------------------------------------

  FormField是一个服务器控件,用它可以呈现一个字段的显示,编辑。FieldName来指定字段名,这个字段名一般是内部名(InternalName),InternalName

  的获取可以采用SharePoint Manager 2007 或Caml Builder之类的软件或自己写点代码来获取.

------------------------------------------------------------------------------------------

<SharePoint:CreatedModifiedInfo ID="CreatedModifiedInfo1" runat="server" />

------------------------------------------------------------------------------------------

  这个很好理解,它显示列表项目的创建修改信息.

------------------------------------------------------------------------------------------

<SharePoint:AttachmentUpload Visible="false" ID="AttachmentUpload1" runat="server" />

------------------------------------------------------------------------------------------

  这个是用来传附件的.既然我们改的是查看页面,不需要上传的功能,就把它隐藏掉了(Visible=false).

------------------------------------------------------------------------------------------

< table border="0" cellspacing="0" cellpadding="0">

    <SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows"

                    runat="server" />

< /table>

------------------------------------------------------------------------------------------

  虽然上传附件不需要,但是显示已经上传的附件还是需要的,这个就是来实现显示附件的.

  它实际并没有什么内容.它的内容是有另外的模板AttachmentRows来实现的,查找DefaultTemplates.ascx可以找到这个模板:

------------------------------------------------------------------------------------------

<SharePoint:RenderingTemplate ID="AttachmentRows" runat="server">

  <Template>

    <TR id=idAttachmentsRow>

    <TD nowrap="true" valign="top" class="ms-formlabel" width="20%">

    <SharePoint:FieldLabel FieldName="Attachments" runat="server"/>

    </TD>

    <TD valign="top" class="ms-formbody" width="80%">

      <SharePoint:AttachmentsField FieldName="Attachments" runat="server"/>

      <SCRIPT>

      var elm = document.getElementById("idAttachmentsTable");

      if (elm == null || elm.rows.length == 0)

        document.getElementById("idAttachmentsRow").style.display='none';

      </SCRIPT>

    </TD></TR>

  </Template>

< /SharePoint:RenderingTemplate>

 <SharePoint:GoBackButton ID="GoBackButton2" Visible="false"                  runat="server" />

------------------------------------------------------------------------------------------

  这个用来返回列表页面.我们自己的按钮代替了它,所有也把它Visible掉了.

  以上的模板不但可以用在查看页面,其他页面也是可以通用的.如果要用到保存页面,需要在模板里加一个保存控件:

<SharePoint:SaveButton runat="server"/>

  修改保存页面,(NewForm.aspx或EditForm.aspx)的ListFormWebPart的TemplateName为CodeArt_NoticeTemplate.

  可以看一下效果:

完全采用SharePoint Designer来定制表单页面#e#

  采用RenderingTemplate定制的模板可以在多个表单页面复用,如果抛弃复用性,完全可以全部用SPD实现.

  第一步--隐藏掉原有的显示区域:设置主要webpart区域visible属性为false.

------------------------------------------------------------------------------------------

<WebPartPages:WebPartZone Visible="false" runat="server" FrameType="None" ID="Main"

------------------------------------------------------------------------------------------

  第二步--直接在Content控件中写模板:

------------------------------------------------------------------------------------------

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

< SharePoint:FormField ID="FormField1" runat="server" FieldName="Title" />

< hr/>

< SharePoint:FormField ID="FormField2" runat="server" FieldName="Body" />

< br/>

< SharePoint:SaveButton runat="server" ID="save" />

< SharePoint:GoBackButton ID="GoBackButton2"                  runat="server" />

< /asp:Content>

------------------------------------------------------------------------------------------

  OK,完工。



  有的人可能要问了:这样定制是不错,但是会丧失很多wss的功能,比如列表可以动态增加字段,这些动态的字段怎么显示出来呢?

  这就要用到ListFieldIterator这个控件了,只要把以下代码嵌入你的模板即可:

<SharePoint:ListFieldIterator runat="server"/>

  要实现完美的定制表单页面,大家最好去研究一下DefaultTemplates.ascx的内容.并要着重研究ListForm模板,所有的List的表单默认都是基于这个模板的.

  ListForm

<SharePoint:RenderingTemplate ID="ListForm" runat="server">

  <Template>

    <SPAN id='part1'>

      <SharePoint:InformationBar runat="server"/>

      <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&nbsp;" runat="server">

          <Template_RightButtons>

            <SharePoint:NextPageButton runat="server"/>

            <SharePoint:SaveButton runat="server"/>

            <SharePoint:GoBackButton runat="server"/>

          </Template_RightButtons>

      </wssuc:ToolBar>

      <SharePoint:FormToolBar runat="server"/>

      <TABLE class="ms-formtable" style="margin-top: 8px;" border=0 cellpadding=0 cellspacing=0 width=100%>

      <SharePoint:ChangeContentType runat="server"/>

      <SharePoint:FolderFormFields runat="server"/>

      <SharePoint:ListFieldIterator runat="server"/>

      <SharePoint:ApprovalStatus runat="server"/>

      <SharePoint:FormComponent TemplateName="AttachmentRows" runat="server"/>

      </TABLE>

      <table cellpadding=0 cellspacing=0 width=100%><tr><td class="ms-formline"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td></tr></table>

      <TABLE cellpadding=0 cellspacing=0 width=100% style="padding-top: 7px"><tr><td width=100%>

      <SharePoint:ItemHiddenVersion runat="server"/>

      <SharePoint:ParentInformationField runat="server"/>

      <SharePoint:InitContentType runat="server"/>

      <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&nbsp;" runat="server">

          <Template_Buttons>

            <SharePoint:CreatedModifiedInfo runat="server"/>

          </Template_Buttons>

          <Template_RightButtons>

            <SharePoint:SaveButton runat="server"/>

            <SharePoint:GoBackButton runat="server"/>

          </Template_RightButtons>

      </wssuc:ToolBar>

      </td></tr></TABLE>

    </SPAN>

    <SharePoint:AttachmentUpload runat="server"/>

  </Template>

< /SharePoint:RenderingTemplate>

SharePoint Designer定制MOSS/WSS表单页面的更多相关文章

  1. 使用SharePoint Designer定制开发员工工作日志系统实例!

    昨天已介绍了一篇<使用SharePoint Designer定制开发专家库系统实例!>,今天继续来介绍使用SharePoint Designer定制开发员工工作日志系统实例,主要功能包括填 ...

  2. 开发日志系列:一个表单页面的呈现与提交(一)——JSON的操作

    JSON操作 引子 最近在做一个表单页面,大概是这个样子的 这里打算用一个JSON存储所有的信息,我们可以理解为,所有东西都存在一个字符串里面.方便,快捷,易读,数据库操作也方便了.甚至,可以将很多不 ...

  3. Dynamics 365 CE命令栏按钮点击后刷新表单页面方法

    微软动态CRM专家罗勇 ,回复326或者20190428可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me! Dynamics 365 Customer Engagement ...

  4. C# Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面

    个人理解,开发应用程序的目的,不论是B/S或是C/S结构类型,无非就是实现可供用户进行查.增.改.删,其中查询用到最多,开发设计的场景也最为复杂,包括但不限于:表格记录查询.报表查询.导出文件查询等等 ...

  5. Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面 z

    http://www.cnblogs.com/zuowj/p/4504130.html 不论是B/S或是C/S结构类型,无非就是实现可供用户进行查.增.改.删,其中查询用到最多,开发设计的场景 也最为 ...

  6. Form提交表单页面不跳转

    1.设计源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...

  7. Spring Security默认的用户登录表单 页面源代码

    Spring Security默认的用户登录表单 页面源代码 <html><head><title>Login Page</title></hea ...

  8. 基于react hooks,zarm组件库配置开发h5表单页面

    最近使用React Hooks结合zarm组件库,基于js对象配置方式开发了大量的h5表单页面.大家都知道h5表单功能无非就是表单数据的收集,验证,提交,回显编辑,通常排列方式也是自上向下一行一列的方 ...

  9. 使用SharePoint Designer定制开发专家库系统实例!

    将近大半年都没有更新博客了,趁这段时间不忙,后续会继续分享一些技术和实际应用.对于Sharepoint的定制开发有很多种方式,对于一般的应用系统,可以使用Sharepoint本身自带的功能,如列表作为 ...

随机推荐

  1. Java中Map的用法详解

    Map简介 将键映射到值的对象.一个映射不能包含重复的键:每个键最多只能映射到一个值.此接口取代 Dictionary 类,后者完全是一个抽象类,而不是一个接口. Map 接口提供三种collecti ...

  2. HTML标签语义对照表

    标签名 英文全拼 中文翻译 div division 分隔 span span 范围 ol ordered list 排序列表 ul unordered list 不排序列表 li list item ...

  3. 【js】IE、FF、Chrome浏览器中的JS差异介绍

    如何判断浏览器类型 转:http://www.cnblogs.com/carekee/articles/1854674.html 1.通过浏览器特有的对象 如ie 的ActiveXObject  ff ...

  4. cocos2dx-Lua中出现的问题

    1,在Lua中print输出失效的问题 在main.lua中添加print=release_print :

  5. (转载)Cocos2dx-OpenGL ES2.0教程:使用VBO索引(4)

    在上一篇文章中,我们介绍了uniform和模型-视图-投影变换,相信大家对于OpenGL ES 2.0应该有一点感觉了.在这篇文章中,我们不再画三角形了,改为画四边形.下篇教程,我们就可以画立方体了, ...

  6. [SQL SERVER系列]读书笔记之SQL注入漏洞和SQL调优

    最近读了程序员的SQL金典这本书,觉得里面的SQL注入漏洞和SQL调优总结得不错,下面简单讨论下SQL注入漏洞和SQL调优. 1. SQL注入漏洞 由于“'1'='1'”这个表达式永远返回 true, ...

  7. XCode6.1中的ios7.1适配

    在xcode6.1中新创建的项目,运行在我的ios7.1的ipod touch上时(与5s的一样的尺寸, Retina屏幕), 上下出现了黑边,由于没有下载7.1的模拟器,不知道模拟器上有无问题, 查 ...

  8. sort-based shuffle的核心:org.apache.spark.util.collection.ExternalSorter

    依据Spark 1.4版 在哪里会用到它 ExternalSorter是Spark的sort形式的shuffle实现的关键.SortShuffleWriter使用它,把RDD分区中的数据写入文件. o ...

  9. Get请求携带数据量的各种限制及解决办法、Post请求说明

    1.   Get请求携带数据量的各种限制及解决办法 Http Get方法提交的数据大小长度并没有限制,HTTP协议规范没有对URL长度进行限制.这个限制是特定的浏览器及服务器对它的限制. 到新公司处理 ...

  10. ios开发--网页中调用JS与JS注入

    先将网页弄到iOS项目中: 网页内容如下, 仅供测试: <html> <head> <meta xmlns="http://www.w3.org/1999/xh ...