[英]Whats wrong with that RadCalendar Code?
i'm trying to highlight comma seperated dates mentioned in textbox to radcalendar 我正在尝试向radcalendar突出显示文本框中提到的逗号分隔日期
Dim calendar As 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))
Code to Highlight textbox comma sepearted dates as 03-sep-2015, 04-sep-2015 on RadCalendar 代码突出显示文本框逗号分隔的日期为RadCalendar的2015年9月3日,2015年9月4日
Protected Sub RadCalendar1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadCalendar1.PreRender
Dim yourCalendar As RadCalendar
If Page.IsPostBack Then
If [String].IsNullOrWhiteSpace(TextBox1.Text) = False Then
'textbox in which dates as stored as comma separated
Dim datesToShow As String() = TextBox1.Text.Split(","c)
For Each [date] As String In datesToShow
yourCalendar.SelectedDates.Add(New DateTime([date]))
Next
End If
End If
End Sub
Both of the code shows an error with bluecolor underline on both code as : 这两个代码都在两个代码上显示了带有蓝色下划线的错误:
Value of type 'Date' cannot be converted to 'Telerik.Web.UI.RadDate'. 类型“ Date”的值不能转换为“ Telerik.Web.UI.RadDate”。
on yourCalendar.SelectedDates.Add(New DateTime([date])) 在yourCalendar.SelectedDates.Add(New DateTime([date]))上
Line 线
The RadCalendar.SelectedDates.Add method is expecting a attribute of the type "Telerik.Web.UI.RadDate" and you're passing in a DateTime type. RadCalendar.SelectedDates.Add方法需要类型为“ Telerik.Web.UI.RadDate”的属性,并且您传入的是DateTime类型。
You should be newing up a RadDate instead of a DateTime. 您应该更新RadDate而不是DateTime。
Looks like RadDate has a Date property which is a DateTime. 看起来RadDate具有一个Date属性,它是一个DateTime。
So instead of 所以代替
calendar.SelectedDates.Add(New DateTime(2008,7,7));
do 做
Dim d = New RadDate()
d.Date = New DateTime(2008, 7, 7)
calendar.SelectedDates.Add(d)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.