![](/img/trans.png)
[英]Using ASP.NET TextBox Control to filter SharePoint ListView WebPart
[英]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.