Reputation: 78683
I want to make a simple ASP.NET page that draws a months from a calendar and highlights given dates. (I'm not looking for a date picker.) What I have is a list of DateTime
values and I need to display them a a nice way.
Given that I'm a total beginner with ASP, simpler really is better. (I'd rather not, I'm willing to hack together something with StringBuilder
and <table>
if it's easier).
p.s. I have no budget, so non-free controls will only be of use to other readers.
Upvotes: 0
Views: 664
Reputation: 9095
It may be too late for this project, but it sounds like BaseCalendar would work.
Upvotes: 0
Reputation: 73604
You can do this with the standard Calendar Control and use the DayRender event to format the individual days. I did something similar to this as my first ASP.Net application (a basic event scheduler) where the special dates were stored in a DB.
<asp:Calendar id = "objCalendar" runat = "server"
onDayRender = "objCalendar_DayRender"
Borderstyle = solid
>
<%
public void objCalendar_DayRender(object sender, DayRenderEventArgs e)
{
CalendarDay d = ((DayRenderEventArgs)e).Day;
string strCurrrentDayDisplay = GetDaySchedule(d.Date.ToShortDateString());
TableCell c = ((DayRenderEventArgs)e).Cell;
if (d.IsOtherMonth)
{
c.Controls.Clear();
}
else
{
try
{
c.Controls.Add(new LiteralControl("<br>" + strCurrrentDayDisplay));
}
catch (Exception err)
{
Response.Write (err.ToString());
}
}
d.IsSelectable = false;
}
%>
Upvotes: 1