[英]How to show comma seperated dates in radcalendar
我的asp.net網頁上有一個文本框,radCalendar和按鈕控件
當我在radcalender中選擇多個日期時,由於我在文本框中添加的radcalender日期中選擇日期,因此動態地將其存儲在文本框中為2015年9月2日,2015年9月3日,2015年9月4日,請檢查以下代碼:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim stringbuilder As StringBuilder = New StringBuilder
For Each selecteddate As RadDate In RadCalendar1.SelectedDates
stringbuilder.Append(selecteddate.Date.ToString("dd-MMM-yyyy") + ", ")
Next
stringbuilder.Length -= 2
TextBox1.Text = stringbuilder.ToString
End Sub
我想要的是 ?
我想如果textbox在page_load事件中已經具有2015年9月3日,2015年9月9日,2015年9月11日的倍數日期,則在禁用頁面加載和其余所有日歷日期時,以下日期是radcalendar中的亮點。
如果您處於SelectionMode=Single
,則可以使用日歷的SelectedDate
屬性設置所選日期,例如:
RadCalendar calendar = new RadCalendar();
calendar.SelectionMode = SelectionMode.Single;
calendar.SelectedDate = new DateTime(2008, 7, 7);
對於其他SelectionModes (Multiple and Extended)
,應使用日歷的SelectedDates
屬性,例如:
RadCalendar calendar = new RadCalendar();
calendar.SelectionMode = SelectionMode.Extended;
calendar.SelectedDates.Add(new DateTime(2008, 7, 7));
calendar.SelectedDates.Add(new DateTime(2008, 7, 8));
calendar.SelectedDates.Add(new DateTime(2008, 10, 10));
因此,請執行以下操作 :
if(Page.IsPostBack){
if( String.IsNullOrWhiteSpace(datestextbox.Text)==false) //textbox in which dates as stored as comma separated
{
string[] datesToShow = datestextbox.Text.Split(',');
foreach (string date in datesToShow)
{
yourCalendar.SelectedDates.Add(new DateTime (date ));
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.