Calendar control to display image on Mondays

D

David

I am trying to get an image to appear on all Mondays within the calendar
control. I also want that image to be a link. How can I do this?
 
S

Steven Cheng[MSFT]

Hi Dilworth,

Welcome to ASPNET newsgroup.
As for the Calendar displaying Image on mondays question, I think we can
make use of the Calendar control's DayRender event, this event occurs when
the Caldenar control try rendering a Day Cell on it(for each day displaying
....). So we can put some code to check whether the current rendered day is
monday, if so, clear the original controls in the cell and add our custom
controls (hyperlink and image controls....). here is just a simple
implementation which use a ASP.NET LiteralControl to inject a hyperlink
with image:

=======================
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
System.Globalization.GregorianCalendar gc = new
System.Globalization.GregorianCalendar();
DayOfWeek dow = gc.GetDayOfWeek(e.Day.Date);
if (dow == DayOfWeek.Monday)
{
LiteralControl lc = new LiteralControl(
@"
<a href='http://www.asp.net'>
<img src='Images/mon.GIF'/>
</a>
"
);
e.Cell.Controls.Clear();
e.Cell.Controls.Add(lc);

}
========================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: Calendar control to display image on Mondays
| thread-index: AcYcN5/Azogx7Mm+RN6qWFOfu4HKTg==
| X-WBNR-Posting-Host: 169.200.185.24
| From: "=?Utf-8?B?RGF2aWQ=?=" <[email protected]>
| Subject: Calendar control to display image on Mondays
| Date: Wed, 18 Jan 2006 06:01:05 -0800
| Lines: 2
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:32559
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| I am trying to get an image to appear on all Mondays within the calendar
| control. I also want that image to be a link. How can I do this?
|
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top