Results 1 to 3 of 3

Thread: Check dimensions of image in gridview and resize before display

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    2

    Check dimensions of image in gridview and resize before display

    I am displaying images in a gridview as thumbnails restricting width and height to 150 and 100 respectively. For portrait size images they are distorted. Is there any way that I can check for image height and width so that I can display reduced in correct proportions

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Check dimensions of image in gridview and resize before display

    VB.NET Code:
    1. Dim img As Image
    2. img = Image.FromFile("C:\Documents and Settings\dsakpal\My Documents\My Pictures\coding.jpg")
    3. MessageBox.Show("Width: " & img.Width)
    4. MessageBox.Show("Height: " & img.Height)

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    2

    Re: Check dimensions of image in gridview and resize before display

    Thanks for reply. Tried solution but problems encountered. Think it is because I'm reading from database record rather than from file. My code in an ItemTemplate within the Gridview is (javascript part simply so get pop-up larger image):
    html Code:
    1. <ItemTemplate>
    2.                     <a href="javascript:openPopup('clcndet.aspx?rid=<%# Eval("ClcnRRecordID") %>&ccde=<%# Eval("ContribCode") %>')"><img height="100" width="150" src='<%# "images/" + Request.QueryString("ccde").ToString + "/" + Eval("ClcnRDigitalFileName") %>' alt="Select for enlarged image"  /></a>
    3.                </ItemTemplate>
    The Image file name is in field ClcnRDigitalFileName.

    Also Image.FromFile and MessageBox.Show are not recognised in my VB.Net (is Web Development)

Posting Permissions

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



Click Here to Expand Forum to Full Width