【问题标题】:How to use SharePoint Field in application page如何在应用程序页面中使用 SharePoint 字段
【发布时间】:2014-02-22 03:13:32
【问题描述】:

我正在创建应用程序页面。在此应用程序页面上,我想更新列表中的一些 SharePoint 字段。

所以我在 aspx 文件中创建了这个:

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">


    <SharePoint:TextField ControlMode="Edit" runat="server" FieldName="Size" ID="SizeField"></SharePoint:TextField>
</asp:Content>

在 cs Page_Load 我有这个

protected void Page_Load(object sender, EventArgs e)
        {

            SPList list = SPContext.Current.Web.Lists["Media Content"];
            SizeField.ListId = list.ID;
            SizeField.ItemId = 5;
}

但是当我加载页面时出现错误。

但是当我添加到 aspx 这个(ListId 和 ItemId 直接在 aspx 中)

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">


    <SharePoint:TextField ControlMode="Edit" runat="server" FieldName="Size" ID="SizeField" ListId="7a00ae8c-9e8d-4762-81a2-a21b76a24ea7" ItemId="5"></SharePoint:TextField>
</asp:Content>

并且cs中的页面加载是空的,它可以正常工作......

但我想在cs代码中动态更改ItemId和ListId....嗯...谢谢

PS:我也尝试在 OnInit 或 CreateChildControls 中添加初始化,但没有成功。谢谢

【问题讨论】:

    标签: sharepoint sharepoint-2013


    【解决方案1】:

    首先,我认为您应该检查 splist 对象是否不返回 null。 然后,您可以创建对象并将它们写入 UI。也许在 aspx 和 cs 上使用带有控件的混合解决方案是行不通的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-02
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 2011-11-04
      相关资源
      最近更新 更多