未应用 SharePoint 自定义控件模板

发布于 2024-08-03 04:31:43 字数 663 浏览 5 评论 0原文

我在使用自定义控件模板时遇到问题。

我的目的是在 NewForm.aspx 上使用自定义控件模板作为列表。

  1. 我创建了一个 CustomTemplate.ascx 文件,并将其部署到 12/Template/CONTROLTEMPLATES

    ...

  2. 我已修改列表的 schema.xml 文件使用我的自定义模板:

我的 NewForm.aspx 页面仍然但是显示默认视图。这适用于基于我的列表模板的新列表和现有列表。我已尝试围绕部署重新启动 IIS,但这没有帮助。

如果我将模板的名称更改为“ListForm”,这将按预期成功覆盖默认模板,并且我可以看到现有列表和新列表中的更改。

我在这个网站和谷歌上寻求帮助,但找不到任何东西。以前有人遇到过这个吗?

I'm having trouble with a custom control template.

My intention is to use a custom control template on a NewForm.aspx for a list.

  1. I have created a CustomTemplate.ascx file and this is deployed to 12/Template/CONTROLTEMPLATES

    <SharePoint:RenderingTemplate ID="CustomListForm" runat="server" >...

  2. I have modified the schema.xml file for the list to use my custom template:

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

My NewForm.aspx page still shows the default view however. This is for both new and existing lists based on my list template. I have tried restarting IIS around deployment but this doesn't help.

If I change the name of my template to "ListForm", this successfully overwrites the default template as expected, and I can see the change in existing and new lists.

I've looked for help on this site and Google, but can't find anything. Has anyone come across this before?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ゞ花落谁相伴 2024-08-10 04:31:43

确保内容类型中的 TemplateName 为 null 或空字符串。 ContentType 中定义的 TemplateName 将覆盖列表架构中定义的任何 TemplateName。

仅供参考,开箱即用的内容类型“Item”将 NewFormTemplateName 设置为“ListForm”,这将覆盖列表架构中定义的任何自定义模板名称。

Make sure the TemplateName in your content type is null or empty string. TemplateName defined in ContentType will override any TemplateName defined in the list schema.

FYI, the out of the box content type 'Item' have NewFormTemplateName set to 'ListForm', this will override any custom template name defined in your list schema.

莫相离 2024-08-10 04:31:43

我猜您在 CustomTemplate.ascx 中的某个地方遇到了错误 -
您可以发布 CustomTempate.ascx 的代码吗?

I would guess that you've got an error somewhere in the CustomTemplate.ascx -
could you post the code of the CustomTempate.ascx ?

梦断已成空 2024-08-10 04:31:43

您执行的所有步骤都是正确的。我过去做过类似的事情并且成功地让它发挥作用。我建议的几件事是尝试编写以下代码,看看您得到的模板是什么。

        SPList oList=SPContext.Current.Web.Lists["YourList"];
        Console.WriteLine(oList.Forms[PAGETYPE.PAGE_NEWFORM].TemplateName);

如果上面的代码返回正确的模板名称,则部署/关联没有问题。模板本身有问题。您可以深入研究 SharePoint 日志。您应该获得更多信息。

All the Steps you have Performed is right. I have done similar things in past and was successful in get it working. Few things I would suggest is try writing following code see what is the template you getting.

        SPList oList=SPContext.Current.Web.Lists["YourList"];
        Console.WriteLine(oList.Forms[PAGETYPE.PAGE_NEWFORM].TemplateName);

If the above code is returning the right Template Name then there is no issue with the deployment / association.Something wrong with the Template itself. You can dig in to the SharePoint Log . You should get more information.

夏有森光若流苏 2024-08-10 04:31:43

嗯,有趣的一点。您是否希望语法错误导致 SharePoint 回退到默认值而不是引发错误?

以下是 CustomTemplate.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"%>
<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<SharePoint:RenderingTemplate ID="CustomListForm" runat="server">
    <Template>
            Test content
    </Template>
</SharePoint:RenderingTemplate>

请注意,我从 DefaultTemplates.ascx 文件中复制了指令。我的文件位于同一目录中。

非常感谢您的帮助!

Hmmm interesting point. Would you expect a syntax error to cause SharePoint to fall back on the default rather than throwing an error?

Here is the code from the CustomTemplate.ascx files:

<%@ 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"%>
<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<SharePoint:RenderingTemplate ID="CustomListForm" runat="server">
    <Template>
            Test content
    </Template>
</SharePoint:RenderingTemplate>

Note that I copied the directives from the DefaultTemplates.ascx file. My file is located in the same directory.

Thanks very much for your help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文