Add Check Box in Calender Control and Select WeekEnds on click of Button

Format Calender Controls :

Add Check Boxes manually in Calender Control and Select Week Ends on click of Button.



Code :
Partial Class SelectWeekEnds
    Inherits System.Web.UI.Page

    Dim btnclick As Boolean = False

    Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
        Dim ctl As New CheckBox
        ctl.ID = "chk" & e.Day.Date.ToString.Substring(0, 10)
        If btnclick = True Then
            If CInt(e.Day.Date.DayOfWeek) = 0 Or CInt(e.Day.Date.DayOfWeek) = 6 Then
                ctl.Checked = True
            End If
        End If
        e.Cell.Controls.Add(ctl)
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        btnclick = True
    End Sub

End Class

No comments:

Post a Comment