calendar DayRender

Rani

Well-known member
Joined
Nov 19, 2005
Messages
71
Programming Experience
Beginner
Can you please change the syntax to this pc of code.
I want to use this on my page behind. I found this code on line. I am not able to fix the syntax. Thanks
VB.NET:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
'Clear the link from this day
e.Cell.Controls.Clear()
'Add the custom link
System.Web.UI.HtmlControls.HtmlGenericControl(Link = New System.Web.UI.HtmlControls.HtmlGenericControl)
Link.TagName = "a"
Link.InnerText = e.Day.DayNumberText
Link.Attributes.Add("href", String.Format("javascript:window.opener.document.{0}.value = \'{1:d}\'; window.close();", _
    Request.QueryString["field"], e.Day.Date))
'By default, this will highlight today's date.
If (e.Day.IsSelected) Then
Link.Attributes.Add("style", this.Calendar1.SelectedDayStyle.ToString());
'Now add our custom link to the page
e.Cell.Controls.Add(Link)
End Sub
 
Last edited by a moderator:
1. Declare the link like this:
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Link [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Web.UI.HtmlControls.HtmlGenericControl[/SIZE]
2. For the QueryString replace C-style brackets [] with VB-style parantesis ().

3. Link.Attributes.Add command ends with the ; character - remove that character, only C languages use this to mark end of instruction. This command is also the only relevant for the If statement so end the If statement or use the single line If statement syntax (If condition Then statement)
 
Back
Top