This post originated from an RSS feed registered with .NET Buzz
by Scott Watermasysk.
Original Post: Calendar Control
Feed Title: ScottW's ASP.NET WebLog
Feed URL: /error.aspx?aspxerrorpath=/blog/rss.aspx
Feed Description: ASP.NET and Blogging
Scott Mitchell has posted a nice article on how to add a calendar control a .Text blog. He is currently using version 0.94. If you choose to drop this control in either version 0.95 or 0.96, I would make the following changes (mostly for consistency)
Instead of deriving from UserControl, derive from .Text's BaseControl. This will get you a reference to the currently requested blog via BaseControl.CurrentBlog
Instead of building the url yourself, use .Text's, UrlFormat class. This way, future url changes (or if you globally decide to change something), can still be done in one place. In addition, in a multi-blog site, the links will point to the correct blog. The instance of UrlFormat you would want to use, is part of the BlogConfig for the current blog (ie, CurrentBlog.UrlFormat). So when you set the value of Cell.Text, it would look something like, Cell.Text = string.Format(“<a href=\“{0}\“>{1}</a>“,CurrentBlog.UrlFormat.DayUrl(e.Day.Date),e.Day.Date.Day);
If you are feeling really adventurous, you can override the OnMonth event and use UrlFormat.MonthUrl to point to the previous and next months.
Either way, its a great contribution. Early versions of .Text included a similar control, but at the time I was having a hard time getting the CSS work properly, so I decided to drop it for now. If you are interested, you can also check out Daniel Cazzulino'sstyle free calendar control which should be much easier to CSS enable.