display booked dates in red color in calender
-
hi i am disabling all past dates and remaining dates in green color with the following code
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{if (e.Day.Date < DateTime.Today)
{e.Day.IsSelectable = false;
e.Cell.ForeColor = System.Drawing.Color.Gray;
}
else
{
e.Cell.ForeColor = System.Drawing.Color.Green;
}} i have two dropdownlists ddlFrom and ddlTo.i vil select dates from these dropdownlists to book a room in a hotel.the dates fromdate to todate should appear in red color...any help is appreciated
-
hi i am disabling all past dates and remaining dates in green color with the following code
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{if (e.Day.Date < DateTime.Today)
{e.Day.IsSelectable = false;
e.Cell.ForeColor = System.Drawing.Color.Gray;
}
else
{
e.Cell.ForeColor = System.Drawing.Color.Green;
}} i have two dropdownlists ddlFrom and ddlTo.i vil select dates from these dropdownlists to book a room in a hotel.the dates fromdate to todate should appear in red color...any help is appreciated
try this .First get from and to date in two variable then compare them
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime FromDate =Convert.ToDateTime(ddlFrom.SelectedValue);
DateTime ToDate =Convert.ToDateTime(ddlTo.SelectedValue);if(e.Day.Date >= FromDate && e.Day.Date <= ToDate )
{
e.Cell.BackColor = System.Drawing.Color.Red;
}
} -
try this .First get from and to date in two variable then compare them
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime FromDate =Convert.ToDateTime(ddlFrom.SelectedValue);
DateTime ToDate =Convert.ToDateTime(ddlTo.SelectedValue);if(e.Day.Date >= FromDate && e.Day.Date <= ToDate )
{
e.Cell.BackColor = System.Drawing.Color.Red;
}
}it doesn't work
-
it doesn't work
it is working!!!!!!....have u set dropdownlists autopostback property to true...for this code it is required
-
it is working!!!!!!....have u set dropdownlists autopostback property to true...for this code it is required
now i have been instructed to use textboxes... now i am using the following code protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) {if (e.Day.Date < DateTime.Today) { e.Day.IsSelectable = false; e.Cell.ForeColor = System.Drawing.Color.Gray; } else { e.Cell.ForeColor = System.Drawing.Color.Green; } if (e.Day.Date >= FromDate && e.Day.Date <= ToDate) { e.Cell.ForeColor = System.Drawing.Color.Red; } } protected void Button1_Click(object sender, EventArgs e) { FromDate = DateTime.ParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); ToDate = DateTime.ParseExact(txtTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } when i run the application the dates which user enters are appearing in red color in calender...but the pbm i am facing is i vil stop running the application & once again re-run application...this time user entered dates are not in red color....they are in green color. the same pbm i faced when i was using dropdownlist....even now also, the same issue i am getting...even when i stop & rerun the application user entered dates should appear in red color...by seeing red color in calender user comes to know that those dates are already booked...so he vil enter other dates..when the user clicks on calender image ,all past dates shoud be disabled....and booked dates in red color and rest of the dates in green color...at the bottom of the page indication is given to user that gray colored dates are not selectable,red colored dates are already booked and green colored dates are available for booking....this is the concept i am using...pls guide me how to solve my issue....
-
now i have been instructed to use textboxes... now i am using the following code protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) {if (e.Day.Date < DateTime.Today) { e.Day.IsSelectable = false; e.Cell.ForeColor = System.Drawing.Color.Gray; } else { e.Cell.ForeColor = System.Drawing.Color.Green; } if (e.Day.Date >= FromDate && e.Day.Date <= ToDate) { e.Cell.ForeColor = System.Drawing.Color.Red; } } protected void Button1_Click(object sender, EventArgs e) { FromDate = DateTime.ParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); ToDate = DateTime.ParseExact(txtTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } when i run the application the dates which user enters are appearing in red color in calender...but the pbm i am facing is i vil stop running the application & once again re-run application...this time user entered dates are not in red color....they are in green color. the same pbm i faced when i was using dropdownlist....even now also, the same issue i am getting...even when i stop & rerun the application user entered dates should appear in red color...by seeing red color in calender user comes to know that those dates are already booked...so he vil enter other dates..when the user clicks on calender image ,all past dates shoud be disabled....and booked dates in red color and rest of the dates in green color...at the bottom of the page indication is given to user that gray colored dates are not selectable,red colored dates are already booked and green colored dates are available for booking....this is the concept i am using...pls guide me how to solve my issue....
is it possible to check e.Cell.ForeColor in if then ur problem may solve.. try it for example and u have store this booked dates in database ..use this link for help http://msdn.microsoft.com/en-us/library/ms228044(v=vs.90).aspx[^]
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
//do databse connectivity
//run while loop store this fromdate and todate in two variable
//do same thing as u have done to display in red fore
if (e.Day.Date < DateTime.Today)
{e.Day.IsSelectable = false;
e.Cell.ForeColor = System.Drawing.Color.Gray;
}
else
{
if(e.Cell.ForeColor != System.Drawing.Color.Red)
e.Cell.ForeColor = System.Drawing.Color.Green;
}
if (e.Day.Date >= FromDate && e.Day.Date <= ToDate)
{
e.Cell.ForeColor = System.Drawing.Color.Red;
}
}