[英]Add the Date Filter SharePoint webpart to an ASP.Net page
How do I add the out-of-the-box SharePoint date filter webpart to an ASP.Net web page? 如何将开箱即用的SharePoint日期筛选器Webpart添加到ASP.Net网页?
I want to do it either in an ASPX... 我想在ASPX中执行此操作...
<%@ Register Assembly="<DateFilterDLL??>" Namespace="<??>" TagPrefix="DP" %>
<...>
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>
<...>
<ZoneTemplate>
<DP:<DateFilterWebPart??> ID="DateFilter" runat="server" />
or programmatically, in the ASPX.CS 或以编程方式在ASPX.CS中
protected void Page_Load(object sender, EventArgs e)
{
this.Controls.Add(<Microsoft.Something.DatePicker??>
}
In your code behind add a reference to Microsoft.Sharepoint and Microsoft.Sharepoint.WebControls 在后面的代码中,添加对Microsoft.Sharepoint和Microsoft.Sharepoint.WebControls的引用
Then declare DateTimeControl dtc; 然后声明dtc的DateTimeControl;
In your page Load or Page Init just use dtc=new DateTimeControl(); 在页面加载或页面初始化中,只需使用dtc = new DateTimeControl();即可。 this.Controls.Add(dtc); this.Controls.Add(DTC);
This should add the datecontrol. 这应该添加datecontrol。 Let me know if u face some issue 让我知道你是否遇到问题
It will be easier to use standard SharePoint DateTimeControl. 使用标准SharePoint DateTimeControl将更加容易。 Here is a common method for this with DateTimeControl, hope it will help someone with the same issue. 这是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.