How to determine whether selected date is todaysdate or Weekend

Manideepgoud
Posted by Manideepgoud under ASP.NET category on | Points: 40 | Views : 531
In order to define whether selected date is todays date or weekend using ASP.NET

In aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Load.aspx.cs" Inherits="Load" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="calender1" runat="server" OnDayRender="Render">
<DayHeaderStyle BackColor="#99CCCC" ForeColor="green" Height="1px" />
<TitleStyle Backcolor="Red" ForeColor="Yellow"/>
</asp:Calendar>
</div>
</form>
</body>
</html>


In aspx.cs page

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Load : System.Web.UI.Page
{
protected void Render(Object Sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:red;\">TodaysDate</p>"));
}
if (e.Day.IsWeekend)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:blue;\">Weekend</p>"));
}
}
}

Comments or Responses

Login to post response