Text below an image

R

Rajesh

Hi all,

Im gonna display a list of images in an aspx page from sql server Db.Each
image has a link.When someone clicks the image i want the width and size of
the image to be displayed at the bottom of the image without any coding at
code-behind because the resulting page will display only the image.

Rajesh
 
D

Dan

"i want the width and size of the image to be displayed at the bottom of the
image ..."

"...the resulting page will display only the image"

Please explain? What is it you are asking?
 
D

Dan

So the question is.

How do you display the width/height dimensions of an image?

Wouldnt that be easier, but maybe this is due to a language barrier so i
apologise if that is the reason.

Use System.Drawing.Image class. Load your image in and then retrieve the
width/height attributes.
 
R

Rajesh

Alright , Say we have this image link
http://www.theserverside.net/articles/content/CreatingProfileProvider/Creati
ngProfileProvider.gif
What do you see? Just an image right?.
In my situation the image is in the form of a binary file inside sql server
database.Now i retreive and display say 10 images.When i click an image it
goes to another page that displays the image say like the link i showed u
above.Now under this image i want to a text to be displayed showing me the
width and size of the image.
Still not clear?
 
G

Guest

Hi

try the following code and let me know

<html>
<head>
<script>
function CheckImageSize()
{
var imgObj = document.getElementById("img1");

document.getElementById("det").innerText = "Width : " + imgObj.width + "
Height : " + imgObj.height
}
</script>
</head>
<body onload="CheckImageSize()">
<table>
<tr>
<td>
<img id="img1"
src="http://www.theserverside.net/articles/content/CreatingProfileProvider/CreatingProfileProvider.gif" border="0">
<br>
<span id="det"></span>
</td>
</tr>
</table>
</body>
</html>
 
D

Dan

Hi Rajesh,

Your really not making sense so this is the last post i will try since i
cant help. Amazed the option of 'maybe i am not being clear' hasn't occurred
just that i am getting it wrong. Perhaps coder arrogance is why you can't
solve a very simple problem?

You want to write the width and height of your image when loaded from a sql
server db underneath the image.

So you have a picture and underneath its dimensions.

Now when i said you want to retrieve the image width/height i just didnt add
that you want to write them out to the screen ( i assumed this would be
obvious once you had it).

Anyway use the code i gave before and get the image from your sql server db,
load it from there into the image class.

Then use that class to give you the width and height then Response.Write it
out to the page under the image. That will give you an image and underneath
it the dimensions printed.

I am using the code behind. If you dont want to then go javascript way as
the other person posted and do it client side.
 
K

KMA

Actually, I think he got it right. He didn't supply pastable code, but the
hint is spot on. when you come to place the link on the page, open the file
yourself (in server code, I mean; not you personally) using the class
indicated, then find out the information you want and output to your page an
additional piece of text with this information. The net result will be a
link followed by the text showing the dimentions.
 
M

Mark S. Milley, MCAD (BinarySwitch)

Or you could use this:

<html>
<script>
function setImgPlaceHolder(){
oDiv=document.getElementById("imgPlaceHolder");
oDiv.innerHTML=oDiv.innerHTML + '<br>' + oDiv.children[0].width + ' x
' + oDiv.children[0].height;
}
</script>
<body onload="setImgPlaceHolder();">
<div id="imgPlaceHolder" style="position:relative;text-align:center;
font-weight:bold;">
<img src="http://www.google.com/logos/Logo_25wht.gif">
</div>
</body>
</html>
 
R

Rajesh

Dan,

Thanks for everything but this is what they asked me in an interview from
Microsoft thats the reason why i couldnt paste any code out here for you
guys to know what im asking.

Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top