ASP.Net Calendar - Default height/width?

  • Thread starter Thread starter todd.freed
  • Start date Start date
T

todd.freed

Hi All,

I am using the <asp: Calendar> object. In the OnDayRender event handler
I am putting text into certain day boxes, and leaving others blank. The
effect is that some months have no additonal text rendered, some months
will have 2 weeks(rows) with no additional content and 1 week with 2 or
3 rows of rendered text. Essentially, the size of the Calendar
fluctuates depending on the data im rendering.

Setting the width property is not a problem and solves the fluctuation
on that axis; however, if I set the height property to, say, 500, then
on a month with 3 blank rows and 1 row with 5 lines of text, the other
rows get squished down .... If I dont specify the height, then the
whole calendar goes tiny on months with no data.

At no point will any row have to hold more than 5 lines of 8pt text.

What I am thinking would be the perfect fix is if I could specify that
every row of the calendar table default to 5 lines of height no matter
what ... then the calendar would always keep a uniform size.

Problem is, not sure how to do that.

Appreciate any input, thanks
 
This probably depends on the way you're adding your rows to each day cell.
My two suggestions would be:

1) Create a panel object that you will add to each day cell. For the days
without anything, you would simply add the following to your panel control:

CalPanel.Controls.Add("&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br
/>&nbsp;");

2) Create a table control that will have 5 rows with each of your blank rows
set as follows:

trCalendar = new TableRow();
tcCalendar = new TableCell();
tcCalendar.Text = "&nbsp;";
trCalendar.Cells.Add(tcCalendar);
tblCalendar.Rows.Add(trCalendar);

This assumes that you will only be using one column within the table.

With either one of these, you can create a user control to handle the
details so that your main application will only be concerned with adding
content to the non-blank rows.

Hope this helps!
 
Thanks Chris, I think #1 is the perfect solution.

Funny thing is I mentioned this problem to my wife. She was like, "just
click on the small boxes and push enter 5 times." Its always the
simplest solution that eludes us the most!!
 
Back
Top