using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace eCateDotNet.include { /// /// Summary description for datepicker_calendar. /// public partial class datepicker_calendar : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { //if the frame querystring is specified, hide the frame panel // and display the calendar panel if (Request.QueryString["frame"] != null) { pnlCalendar.Visible = true; pnlIFrame.Visible = false; //if the page isn’t posting back to it’s self, set date to the one //specified in the querystring if (!Page.IsPostBack) { //set the specified date within a try/catch block //to make sure that it’s a valid date. try { Calendar1.SelectedDate = Convert.ToDateTime(Request.QueryString["date"]); } catch { //if the date passed to the application //isn't valid, set the date to today. Calendar1.SelectedDate = DateTime.Now; } //set the date being displayed to the selected date //by default, the visible date is today’s date Calendar1.VisibleDate = Calendar1.SelectedDate; } } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { } #endregion //the function to render the days of the calendar as specified by us protected void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e) { //clear the controls that are rendered automatically //by the calendar control e.Cell.Controls.Clear(); //Create a new link control System.Web.UI.HtmlControls.HtmlGenericControl Link = new System.Web.UI.HtmlControls.HtmlGenericControl(); Link.TagName = "a"; Link.InnerText = e.Day.DayNumberText; //set the href value to the javascript function to select the date Link.Attributes.Add("href", "Javascript:SelectDate('" + e.Day.Date.ToString("dd/MM/yyyy") + "');"); //set the color of the link Link.Attributes.Add("style", "color:#000000;"); //add our link control to the day e.Cell.Controls.Add(Link); } } }