如何将开箱即用的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??>
}
答案 0 :(得分:1)
在您的代码中添加对Microsoft.Sharepoint和Microsoft.Sharepoint.WebControls
的引用然后声明DateTimeControl dtc;
在您的页面中加载或Page Init使用 dtc = new DateTimeControl(); this.Controls.Add(DTC);
这应该添加datecontrol。如果你面临一些问题,请告诉我
答案 1 :(得分: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