Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP Linking to dynamically generated images...

Options
  • 13-07-2008 7:10pm
    #1
    Registered Users Posts: 5,238 ✭✭✭


    I'm sure there's a perfectly simple way to do this but I can't seem to find it.

    I've created a page(i.e. GetImage.aspx) to return an image based on the request query with works fine in image tags with

    <img src="<%# DataBinder.Eval(Container.DataItem, "URL") %>" border="0"/>

    but if I set it as a link with

    <a href="<%#DataBinder.Eval(Container.DataItem, "URL") %>"></a>

    it displays the image as text.

    Is the only solution to point the href to a page that generates some html too, with image tags setting the image source to something like GetPage.aspx again.

    The purpose is to have a thumbnail link to the full sized image. Oh and I'm using a repeater control in case that's not obvious.

    Any help appreciated. I'm quite capable at putting the code together but don't have a lot of knowledge is this area so I'm pretty clueless about common practices.
    Tagged:


Comments

  • Registered Users Posts: 2,931 ✭✭✭Ginger


    humbert wrote: »
    I'm sure there's a perfectly simple way to do this but I can't seem to find it.

    I've created a page(i.e. GetImage.aspx) to return an image based on the request query with works fine in image tags with

    <a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>" border="0"/>

    but if I set it as a link with

    <a href="<%#DataBinder.Eval(Container.DataItem, "URL") %>"></a>

    it displays the image as text.

    Is the only solution to point the href to a page that generates some html too, with image tags setting the image source to something like GetPage.aspx again.

    The purpose is to have a thumbnail link to the full sized image. Oh and I'm using a repeater control in case that's not obvious.

    Any help appreciated. I'm quite capable at putting the code together but don't have a lot of knowledge is this area so I'm pretty clueless about common practices.
    Try using img tags rather than hyperlinks.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I'm not totally sure I understand, do you want
    <a href="<%#DataBinder.Eval(Container.DataItem, "URL") %>"></a>
    to display an image which is also a hyperlink? Or do you want it to display a link that when clicked on brings you to your aspx page which is in fact in image?

    If it's the latter I presume you are already writing the image back to the response object since it's showing up when you use the image tags. You might just need to set the response objects content type if you're not already, I think you want to set it to "image/jpeg" (if you're returning it as a jpg image of course)


  • Registered Users Posts: 5,238 ✭✭✭humbert


    Thanks, I wasn't setting the content type. Once I did it worked perfectly.


Advertisement