Dynamically set Content in code-behind?

5 posts, 1 answers
  1. Tim Anderson
    Tim Anderson avatar
    6 posts
    Member since:
    Apr 2008

    Posted 08 Jul 2008 Link to this post

    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.
  2. Tim Anderson
    Tim Anderson avatar
    6 posts
    Member since:
    Apr 2008

    Posted 09 Jul 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 10 Jul 2008 Link to this post

    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
  5. Tim Anderson
    Tim Anderson avatar
    6 posts
    Member since:
    Apr 2008

    Posted 10 Jul 2008 Link to this post

    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.)

  6. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 14 Jul 2008 Link to this post

    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 />
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017