Mega Code Archive

 
Categories / ASP.Net / Asp Control
 

Controlling the Appearance of Individual Cells of Dates (VB net)

<%@ Page Language=VB Debug=true %> <script runat=server> Sub DateDisplayed(source As Object, e As DayRenderEventArgs)     If e.Day.Date.Month = "2" and e.Day.Date.Day = "14" Then         e.Cell.BackColor = System.Drawing.Color.Red         e.Cell.ForeColor = System.Drawing.Color.Yellow     ElseIf e.Day.Date.Month = "12" and e.Day.Date.Day = "25" Then         e.Cell.BackColor = System.Drawing.Color.Green         e.Cell.ForeColor = System.Drawing.Color.Red     ElseIf e.Day.Date.Month = "10" and e.Day.Date.Day = "31" Then         e.Cell.BackColor = System.Drawing.Color.Orange         e.Cell.ForeColor = System.Drawing.Color.Black     End If End Sub </SCRIPT> <HTML> <HEAD> <TITLE>Controlling the Appearance of Individual Cells of Dates in the Calendar Control</TITLE> </HEAD> <BODY LEFTMARGIN="40"> <form runat="server"> Select a Date <BR><BR> <asp:Calendar      id="Mycal"      runat="server"     cellpadding="3"     cellspacing="3"     ondayrender="DateDisplayed" /> </form> </BODY> </HTML>