Calendar control
in calendar i want to set particular date as meeting day, appointment day etc. when i click the particular date i want display a message selected date is meeting day etc. i want each date to display in different color how to do in c#.with example.
Satyapriya NayakPosted Feb 11, 2012, 3:44 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication9.WebForm2" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
namespace WebApplication9
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.DayNumberText.ToString() == "18")
{
e.Cell.Attributes.Add("onclick", "javascript:alert('Today date is meeting day')");
e.Cell.ForeColor = Color.Red;
}
if (e.Day.DayNumberText.ToString() == "20")
{
e.Cell.Attributes.Add("onclick", "javascript:alert('Today date is appointment day')");
e.Cell.ForeColor = Color.Green;
}
}
}
}
Thanks
If this post helps you mark it as answer
Satyapriya NayakPosted Feb 10, 2012, 3:57 AM
Another way
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication9._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
namespace WebApplication9
{
public partial class _Default : System.Web.UI.Page
{
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date.Day == 18)
{
e.Cell.Controls.Add(new LiteralControl("
meeting"));
e.Cell.BackColor = System.Drawing.Color.Yellow;
}
else if (e.Day.Date.Day == 20)
{
e.Cell.Controls.Add(new LiteralControl("
myAppointment"));
e.Cell.BackColor = System.Drawing.Color.Red;
}
}
}
}
Thanks