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