【问题标题】:Getting custom form to work in Sharepoint 2010让自定义表单在 Sharepoint 2010 中工作
【发布时间】:2013-02-26 19:44:55
【问题描述】:

我为页面构建了一个自定义的新表单,并在架构文件中执行了以下操作:

<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main" />

所以它会寻找我的自定义表单,它适用于我创建的新客户,但系统中已经存在的客户仍然指向标准的新表单

<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /> 

所以我尝试创建一个升级规则,让老用户通过这样做来查看自定义表单:

var list = web.TryGetList("Client Programs");
list.DefaultNewFormUrl = "NewForm.aspx";
list.Update();

但是我有一种感觉这不会做任何事情,有没有办法通过网站设置页面将旧数据指向新的自定义表单,或者我需要在升级规则中添加/更改什么来获得这行得通吗?

更新

我还应该提到,在表单的属性中,我已将其更改为在配置单元中查找表单并将其设为元素文件。

谢谢

【问题讨论】:

    标签: c# sharepoint sharepoint-2010 schema


    【解决方案1】:

    现有项目由 EditForm.aspx 编辑,而不是来自 newform.aspx

    您必须复制 newform.aspx 并将其命名为 editform.aspx(可以创建一个 displayform.aspx)。

    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomDisplay.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomEdit.aspx" UseLegacyForm="True" WebPartZoneID="Main"  />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomNew.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
    </Forms>
    

    对于每个表单,每个 SharePoint 表单字段都必须使用正确的控制模式进行标记

    新表格:

    <SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="New" FieldName="YourFieldName" />                                
    

    编辑表格:

    <SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="Edit"                                                    FieldName="YourFieldName" />
    

    显示表格:

    <SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="Display"                                                        FieldName="YourFieldName" />
    

    【讨论】:

    • 我的问题可能措辞不正确,不是我要编辑某些内容,而是我要添加新记录。当我对新客户端执行此操作时,它会显示自定义的新表单,但对于预先存在的客户端,它仍会显示旧的新表单。
    猜你喜欢
    • 1970-01-01
    • 2018-10-24
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 2019-02-15
    • 2011-08-26
    • 1970-01-01
    相关资源
    最近更新 更多