Results 1 to 3 of 3

Thread: datalist question

  1. #1
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 03
    Location
    Back in the doghouse
    Posts
    291

    datalist question

    Hi everyone

    I have a datalist bound to an xml file. The datalist displays a series of nature photographs and some information about it.

    The more I read about .getthumbnailimage, the more confused I get . So here's my question....

    Is there a way to use .getThumbnailImage to resize the image before it hits the datalist? All the images are in one place on my server.

    Any thoughts? Thanks

  2. #2
    I wonder how many charact
    Join Date
    Feb 01
    Location
    Savage, MN, USA
    Posts
    3,705

    Re: datalist question

    Yes.

    What you need to do is point the imageurl tag (or src for straight up <img> ran at server), to point grab binary data from your server.

    There are more than likely many articles on how to do this if you google for 'get resized image in asp.net' (here's a sample article http://aspnet.4guysfromrolla.com/articles/012203-1.aspx)

    The above article uses a webpage to serve up the image, but that really is silly since you do not need all the overhead and processing a webpage requires. But they do it for simplicity sake.

    The preferred method would be to identify a special extension in a url request that an HttpModule / Handler could intercept, and return a straight binary response, without the processing of creating a webpage just to return binary data.

    If your website is not dependant on performance, you can certainly use the above article's method and it will not matter. On the other hand, if this site is used by many, you should go the HttpModule route.

    Anyway, in a datalist, you can simply define this on your front-size aspx:
    Code:
    <asp:datalist id="_pictureDataList" runat="server">
    <itemTemplate><img id="frontsideimage" runat="server"></itemTemplate>
    </asp:datalist>
    then, in your code-behind:
    Code:
    private void DataList_ItemDataBound(System.Web.UI.WebControls.DataListItemDataBoundEventArgs e)
    {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
     DataRowView row;
     System.Web.UI.HtmlControls.HtmlImage image;
     row = e.Item.DataItem as DataRowView;
     image = e.Item.Controls.FindControl('frontsideimage');
     image.src = row["imageurl"];
    }
    }

  3. #3
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 03
    Location
    Back in the doghouse
    Posts
    291

    Re: datalist question

    nemaroller

    Thanx....got the images resized , but ran into some trouble with embedded thumbnails affecting the quality of the output (included thumbnail & other info in the jpg). I'll have to work on cleaning them later -- I read there are ways to deal with that.

    I've had the 4 guys site on my links for awhile, they have alot of helpful stuff on their site.

    Thanks again

    Cliff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •