将日期筛选器SharePoint Webpart添加到ASP.Net页面

问题描述 投票:0回答:2

如何将开箱即用的SharePoint日期过滤器webpart添加到ASP.Net网页?

我想在ASPX中做到这一点......

<%@ Register Assembly="<DateFilterDLL??>" Namespace="<??>" TagPrefix="DP" %>
<...>
        <asp:WebPartManager ID="WebPartManager1" runat="server">
        </asp:WebPartManager>
<...>
 <ZoneTemplate>
        <DP:<DateFilterWebPart??> ID="DateFilter" runat="server" />

或以编程方式,在ASPX.CS中

protected void Page_Load(object sender, EventArgs e)
{
 this.Controls.Add(<Microsoft.Something.DatePicker??>
}
sharepoint filter datepicker web-parts aspnet-compiler
2个回答
1
投票

在您的代码后面添加对Microsoft.Sharepoint和Microsoft.Sharepoint.WebControls的引用

然后声明DateTimeControl dtc;

在你的页面Load或Page Init中只使用dtc = new DateTimeControl(); this.Controls.Add(DTC);

这应该添加datecontrol。如果你面临一些问题,请告诉我


1
投票

使用标准SharePoint DateTimeControl会更容易。这是使用DateTimeControl的常用方法,希望它能帮助有同样问题的人。

/// <summary>
/// Get common SP DateTimeControl with current DateOnly settings and MethodToProcessDateChanged
/// </summary>
public static DateTimeControl Cd(this bool DateOnly, bool AutoPostBack = false,
DateTime? SelectedDate = null, Func<bool> MethodToProcessDateChanged = null)
{
     var d = new DateTimeControl();
     d.DateOnly = DateOnly;
     d.AutoPostBack = AutoPostBack;
     if (SelectedDate != null)
     d.SelectedDate = SelectedDate.Value;
     if (MethodToProcessDateChanged != null)
          d.DateChanged += (o, e) => { MethodToProcessDateChanged();};
     return d;
}

查看有关如何使用它的更多详细信息here

© www.soinside.com 2019 - 2024. All rights reserved.