Newbie: Image button aspect ratio

G

Guest

I have some image buttons which I am dynamically adding from a database. No
problems so far...

However, when it loads the image using IMAGEURL=, it doesn't keep the
original aspect ratio.

Is there a way to keep this without resizing the control?

Many thanks,

David Whitchurch-Bennett
 
S

Scott M.

The aspect ratio is not affected at all by the ImageURL property. Most
likely you have the height or width of the control set to a value. If you
remove those values from the control, the image will come in at its normal
size, if you want it smaller (but wish to preserve the aspect ratio), then
just set a width or a height for the control but not both.

"David Whitchurch-Bennett"
 
G

Guest

Thanks for that information. What I have in my app is an image button set to
250 x 250, with a thick border which is all part of the visual theme. That is
why I have set the size first. What I want to do is load an image dynamically
in the center of the image button, but keep the image button border the same
size, so the visual theme is preserved.

Is this possible, or will the only way be to place the image button into
another container with a border.
 
S

Scott M.

I think this is more of an issue of having graphics that will fit into a
250x250 space that VS.NET sizing the images for you. Your best bet is to
use a good graphics tool to create images that will fit into that space,
rather than attempt to have VS.NET fit them for you.

"David Whitchurch-Bennett"
 
G

Guest

I already have this. I am using a class that I have written to scale down the
image first for two reasons.

1. To help the page load faster.
2. To prevent people downloading the full size images (photographic website).

Rather than resizing all of my photos, my class takes care of this by
scaling down the image. I pass the maximum width and height, and the image is
scaled down to fit and it maintains the aspect ratio.

When I put the scaled down image into the button, it stetches it out to fit
in both dimensions.

I guess I just asumed there would be a way to display the image without
stretching it out. I can pad the extra pixels in the function to return a
square image if that is a better way.

Thanks for your help. ASP.NET is quite different to what I am used to, but I
am getting there!
 
S

Scott M.

How about putting the image into an image control (not a button image
control) and overlaying the image control on top of your button control?


"David Whitchurch-Bennett"
 

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top