0

如何将现成的 SharePoint 日期筛选器 Web 部件添加到 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??>
}
4

2 回答 2

1

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

然后声明 DateTimeControl dtc;

在您的页面加载或页面初始化中,只需使用 dtc=new DateTimeControl(); this.Controls.Add(dtc);

这应该添加日期控件。如果您遇到问题,请告诉我

于 2010-05-15T19:15:46.487 回答
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;
}

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

于 2019-03-14T13:57:13.707 回答