繁体   English   中英

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

[英]Add the Date Filter SharePoint webpart to an ASP.Net page

如何将开箱即用的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??>
}

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

然后声明dtc的DateTimeControl;

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

这应该添加datecontrol。 让我知道你是否遇到问题

使用标准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;
}

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM