Clearing the days of anydata

R

Ron Harter

I am new to ASP .Net and still learning so please bear with me. I have a
calendar control where I need the days that are not part of the current
month to be empty. I can't find anything in the documentation on how to do
this so I ended up setting the foreground and background color to be the
same for the OtherMonthDayStyle. Data is still being rendered in the cell
for that day but it is invisible.

This seems kludgey to me and I was wondering of anyone has a cleaner way to
not show anything.
 
S

Stan

I am new to ASP .Net and still learning so please bear with me. I have a
calendar control where I need the days that are not part of the current
month to be empty. I can't find anything in the documentation on how to do
this so I ended up setting the foreground and background color to be the
same for the OtherMonthDayStyle. Data is still being rendered in the cell
for that day but it is invisible.

This seems kludgey to me and I was wondering of anyone has a cleaner way to
not show anything.

Try this in the RenderDay event

if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear(); // remove the date selector link
button
e.Cell.Text = " "; // insert a placeholder for the
empty cell
}

Note that since the calendar is rendered as a table, the empty cell
must contain something to preserve the structure. Hence the  
character (non-break space).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,073
Messages
2,570,539
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top