Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2004, 02:14 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default datalist and images(get width and height)

Hi,

I have a datalist which receives images from the database. I want to open the pictures in a new window. The window must open according to the image's width and size (each picture has different dimensions).
The user clicks an image in the datalist and a new window open. However, I am not sure how to define the width and height for each picture.

Thanks

My code:

<code>
ASPX:
<script language=javascript>
function changeSize(image)
{
var width=images.width;
var height=images.height;
imPrev = window.open(image.src, 'imagePreview', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width='+width,height='+height,l eft = 100,top = 100');

}

</SCRIPT>
<asp:datalist id="ImageList" runat="server" RepeatDirection="Horizontal" RepeatColumns="5">
<ItemTemplate>
<img src="ModelImages/<%=classify_id%>/<%=worker_id%>/<%#Container.DataItem%>?p=<%=DateTime.Now%>" width=50 height=60 hspace=5 border="0" onClick="changeSize(this);" style="cursor:hand;">
</ItemTemplate>
</asp:datalist>

CODEBEHIND:
 Function fillImgList() 'FILL DATALIST WITH IMAGES BUT HOW DO I GET THE SIZE OF THE IMAGE TO USE IN JAVASCRIPT?

        ' Obtain Product Details
        Dim Models As Components.WorkersDB = New Components.WorkersDB
        Dim mydr As SqlDataReader = Models.GetWorkerDetails(Worker_Id)
        mydr.Read()

        PicAr = New ArrayList

        Dim i As Integer
        For i = 1 To 6
            'If there is an image in db
            If mydr("Image" & i.ToString) <> "" Then
                Dim imgId As String = mydr("Image" & i.ToString)

                Dim imgExt As String

                If imgId <> "" Then
                    PicAr.Add(imgId)
                End If
            End If
        Next

        ImageList.DataSource = PicAr
        ImageList.DataBind()

    End Function
</code>


 
Old August 4th, 2004, 08:24 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

For each image that you are going to display, you can open the image using the System.Drawing classes. You can create a new System.Drawing.Image from the file, then get the image's characteristics (dimensions, color depth, all sorts of things). Be sure to resolve the absolute path of the image before you try to open it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Get image height and width Dj Kat Javascript How-To 10 June 4th, 2009 01:49 PM
Chapter 2: width/height mcleod BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 5 May 24th, 2007 09:55 PM
get the height and width of an image with js crmpicco Javascript How-To 1 August 30th, 2006 11:26 PM
how can I get width/height of a picture? keyvanjan Classic ASP Basics 2 May 29th, 2006 07:29 AM
Height and Width? venkatesh_anmca Beginning VB 6 0 January 31st, 2005 05:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.