How to select weekend dates in calender control on button click

Posted by Girinarra under ASP.NET on 12/14/2009 | Views : 2123 | Status : [Member] | Replies : 5
Hi All,

How to select a weekend dates in calender control Please let me know......

Thanks in advance...




Responses

Posted by: Chikul on: 12/15/2009 [Member] Bronze

Up
0
Down
Hi Girinarra,

Do you want to select Current weekend (Date selected on Date Control) . Like click on button it should select Saturday & sunday.
Please specify.


Girinarra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chikul on: 12/15/2009 [Member] Bronze

Up
0
Down
Hi Girinarra,

Following is the code to select Weekend dates in calender control.

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

'To select SaturDay in the selected week
Calendar1.SelectedDates.Add(Calendar1.SelectedDate.AddDays(6 - CInt((Calendar1.SelectedDate).DayOfWeek)))
'To select Sunday in the selected week
Calendar1.SelectedDates.Add(Calendar1.SelectedDate.AddDays(7 - CInt((Calendar1.SelectedDate).DayOfWeek)))
End Sub


Regards,
Chikul

Girinarra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Girinarra on: 12/15/2009 [Member] Starter

Up
0
Down
Thanks for your quick reply chikul.
I added check boxes to beside of each date in calender control and i have a button called Select weekned dates in that buttion event i have to select all the weekend CheckBoxes.
Help me on this.
Thanks

Girinarra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chikul on: 12/18/2009 [Member] Bronze

Up
0
Down
Do u want for Current Month Week end or all the Week end displaying in calender control ?

Girinarra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chikul on: 12/18/2009 [Member] Bronze

Up
0
Down
You can check the week ends using the following codes.

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


you can refer :
http://knowledgeparlour.blogspot.com/2009/12/add-check-box-in-calender-control-and.html

Regards,
Chikul

Girinarra, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response