Click here to Skip to main content
16,021,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change the Colour of a Calander in Web Application?

please help me sir.....
Posted

something like

VB
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
     Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
     Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
     Dim rowBackColor As String = String.Empty
     e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
     e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
 End Sub




see the following link for more tips on calendar control:

http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx[^]
 
Share this answer
 
Comments
Rajesh Anuhya 6-Jan-12 1:40am    
Good link, have my +5
Just checked out this code, very helpful !

Concerning the "My background color changes and doesn't come back" comment, here is what I did :
VB
Protected Sub Main_Calendar_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Main_Calendar.DayRender
Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
Dim DayColor As String = "this.style.backgroundColor='#99CCCC'"
Dim BackColor As String = "this.style.backgroundColor='White'"



If e.Cell.BackColor = Drawing.Color.FromArgb(153, 204, 204) Then
If Not e.Day.IsWeekend Then
e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
e.Cell.Attributes.Add("onmouseout", DayColor)

End If

Else
If Not e.Day.IsWeekend Then
e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
e.Cell.Attributes.Add("onmouseout", BackColor)
End If
End If

End Sub

I created as many variables as different colors on the calendar.
Then, with an "if" statement, I check the color of the day. If it's blue, it will become blue again on "mouseout", or white otherwise.

Hope this helped.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900