This is a migrated thread and some comments may be shown as answers.

Dynamically set Content in code-behind?

4 Answers 168 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Tim Anderson
Top achievements
Rank 1
Tim Anderson asked on 09 Jul 2008, 02:48 AM
I have declared 31 generic DayTemplate controls each with an img src in the Content section.

In my Page_Load I dynamically assign the appropriate DayTemplate to my calendar using SpecialDays.Add.

The reason I do this dynamically is because I would like to manipulate each "img src" as needed.

Is there an easy way to change the "img src..." value for my DayTemplate items as I assign them to their special days?

(In other words, I have a unique image for every day of the month, so I need to change them on the fly.)

thanks for any thoughts on this.

4 Answers, 1 is accepted

Sort by
0
Tim Anderson
Top achievements
Rank 1
answered on 09 Jul 2008, 05:42 PM
I am not sure if this is the "best" way, but what I have decided to do is simply brute-force manipulation of the img src value directly in the e.Cell.Text in the DayRender event.
0
Accepted
Missing User
answered on 10 Jul 2008, 10:16 AM
Hi Tim,


Please find attached a sample web application that demonstrates the needed approach. Give it a try and let me know if your have other questions and/or problems.

Regards,
Plamen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Tim Anderson
Top achievements
Rank 1
answered on 11 Jul 2008, 03:15 AM
Thank you, that sample does answer my original question, so I'll mark it as a solution. Originally I was going to generate actual image files and save them in the images folder (Img/ in your example).

However, while working around the original issue I came up with the other idea and I am sticking with it as it as it allows me to bypass disk based image url's altogether (I now reference an aspx with a dynamically embedded query string for each calendar day that causes the referenced aspx to generate the custom image as a memory stream returned as an HTTP image.)

0
plamen
Top achievements
Rank 1
answered on 14 Jul 2008, 11:21 AM
hi:)

This demo project represents how to write/read binary image data from MS SQL 2005. The code library will teach you how to retrieve, edit and insert image from the database and how to display it in RadGrid control or other asp.net control. It uses ADO.NET as the data access mechanism.

Regards...
<John:Peel />
Tags
Calendar
Asked by
Tim Anderson
Top achievements
Rank 1
Answers by
Tim Anderson
Top achievements
Rank 1
Missing User
plamen
Top achievements
Rank 1
Share this question
or