sharepoint changecontenttype下拉列表

时间:2013-03-01 19:35:06

标签: sharepoint sharepoint-2010 contenttype

SharePoint ChangeContentType DropDown

我已将应用程序页面附加到基于自定义文档的内容类型作为其编辑表单。 该内容类型正在文档库中使用,该文档库附加了多个内容类型。

SharePoint表单字段控件正确呈现相应字段。 更改内容类型控件也会在下拉列表中列出与列表相关的所有内容类型。但是当我更改选择时,意味着当我选择不同的内容类型时,表单不会显示所选内容类型的字段集,而是保持原样。

代码:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="DMS_POC.Layouts.DMS_POC.ApplicationPage1" DynamicMasterPageFile="~masterurl/default.master" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="../../../_controltemplates/15/ToolBar.ascx" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
            <table>
            <tr>
                <td>
                    <span id='part1'>
                        <SharePoint:InformationBar ID="InformationBar1" runat="server" />
                        <div id="listFormToolBarTop">
                            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;#160;" runat="server">
                                <template_rightbuttons>
                                    <SharePoint:NextPageButton ID="NextPageButton1" runat="server"/>
                                    <SharePoint:SaveButton ID="SaveButton1" runat="server"/>
                                    <SharePoint:GoBackButton ID="GoBackButton1" runat="server"/>
                                </template_rightbuttons>
                            </wssuc:ToolBar>
                        </div>

                        <SharePoint:ItemValidationFailedMessage ID="ItemValidationFailedMessage1" runat="server" />
                        <table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
                            <SharePoint:ChangeContentType ID="ChangeContentType1" runat="server" />
                            <SharePoint:FolderFormFields ID="FolderFormFields1" runat="server" />


                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_ProposalNumber" runat="server" FieldName="ProposalNo" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_ProposalNumber" runat="server" FieldName="ProposalNo"
                                        ControlMode="Display" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_CustName" runat="server" FieldName="CustomerName" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_CustName" runat="server" FieldName="CustomerName"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_ProposalType" runat="server" FieldName="ProposalType" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_ProposalType" runat="server" FieldName="ProposalType"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_RevertBy" runat="server" FieldName="RevertBy" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_RevertBy" runat="server" FieldName="RevertBy"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td style="vertical-align:top">
                                    <SharePoint:FieldLabel ID="lbl_Details" runat="server" FieldName="Details" />
                                </td>
                                <td style="vertical-align:top">
                                    <SharePoint:FormField ID="field_Details" runat="server" FieldName="Details"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_SignRequired" runat="server" FieldName="DigitalSignatureRequired" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_SignRequired" runat="server" FieldName="DigitalSignatureRequired"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_Amount" runat="server" FieldName="Amount" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_Amount" runat="server" FieldName="Amount"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <tr>
                                <td colspan="2">&nbsp;</td>
                            </tr>

                            <tr>
                                <td>
                                    <SharePoint:FieldLabel ID="lbl_Final" runat="server" FieldName="Final" />
                                </td>
                                <td>
                                    <SharePoint:FormField ID="field_Final" runat="server" FieldName="Final"
                                        ControlMode="Edit" />
                                </td>
                            </tr>

                            <SharePoint:ApprovalStatus ID="ApprovalStatus1" runat="server" />
                            <SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows" ComponentRequiresPostback="false" runat="server" />
                        </table>
                        <table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px">
                            <tr>
                                <td width="100%">
                                    <SharePoint:ItemHiddenVersion ID="ItemHiddenVersion1" runat="server" />
                                    <SharePoint:ParentInformationField ID="ParentInformationField1" runat="server" />
                                    <SharePoint:InitContentType ID="InitContentType1" runat="server" />
                                    <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;#160;" runat="server">
                                        <template_buttons>
                                    <SharePoint:CreatedModifiedInfo ID="CreatedModifiedInfo1" runat="server"/>
                                </template_buttons>
                                        <template_rightbuttons>
                                    <SharePoint:SaveButton ID="SaveButton2" runat="server"/>
                                    <SharePoint:GoBackButton ID="GoBackButton2" runat="server"/>
                                </template_rightbuttons>
                                    </wssuc:ToolBar>
                                </td>
                            </tr>
                        </table>
                    </span>
                </td>
                <td valign="top">
                    <SharePoint:DelegateControl ID="DelegateControl1" runat="server" ControlId="RelatedItemsPlaceHolder" />
                </td>
            </tr>
        </table>

</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Application Page
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
My Application Page
</asp:Content>

1 个答案:

答案 0 :(得分:0)

这是一个古老的问题,但在寻找其他东西时到了这里。 如果您从未找到解决方案或其他人在这里结束,那么您需要做什么

在您的aspx中添加以下内容:

<tr><SharePoint:ListFieldIterator  runat="server" ID="ListFieldIterator1" ControlMode="Edit" ExcludeFields="FileLeafRef"/></tr>

这将允许ChangeContentType控件根据内容类型刷新字段。您也不需要所有这些硬编码的表单字段,因为ListFieldIterator的目的是为您呈现具有正确控件的表单。

您的下一个问题可能是设置每个控件的值,假设这是您想要做的。对于每种控件类型,您必须查看控件并查找TextBox或DropDownList等控件。大多数情况下控件将深入到内部,如((TextBox)control.Controls [1] .Controls [0 ]。对照[2])。文本 不是最优雅的方式,但这是我能找到的所有工作。

如果您不需要映射值,那么我的答案的第一部分就是您所需要的,而且应该很容易做到。

祝你好运!