using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Drawing; public partial class calendar : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["calDate"] != "" && Request.QueryString["calDate"] != null) { string calDate = Request.QueryString["calDate"]; Calendar1.SelectedDate = DateTime.Parse(calDate); Calendar1.TodaysDate = DateTime.Parse(calDate); } else { Calendar1.SelectedDate = DateTime.Today; Calendar1.TodaysDate = DateTime.Today; } } } protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.IsSelected) { Calendar1.DayStyle.BackColor = Color.Tomato; } if (e.Day.IsOtherMonth == true) { e.Cell.Text = ""; } if (e.Day.IsOtherMonth == false) { e.Cell.Attributes["onmouseover"] = "this.style.backgroundColor='#b0e260';"; } if (Calendar1.DayStyle.BackColor != Color.Empty) { e.Cell.Attributes["onmouseout"] = "this.style.backgroundColor='" + Calendar1.DayStyle.BackColor.ToKnownColor() + "';"; } else { if (e.Day.IsSelected == false) { e.Cell.Attributes["onmouseout"] = "this.style.backgroundColor='#e7facc';"; } } } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { string returnDate = Calendar1.SelectedDate.ToString("MM/dd/yyyy"); Response.Redirect("eventsByDay.aspx?calDate=" + returnDate); } protected void Calendar1_Load(object sender, EventArgs e) { Calendar1.SelectedDates.Clear(); } }