473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting image size

Hi,
how can I retrieve the height and width of
a System.Web.UI.WebControls.Image after populating it's ImageUrl property.
It's seems not to be filled ?
Does someone have a solution ?
Thanks
Karim

Nov 18 '05 #1
3 4219
You can't. These values aren't available at that time because the image
itself isn't loaded into the form. All it's doing is telling the browser
where to get the image from. The width and height can be set independantly
of the image. For example. you can specify a 100 pixel width for an image
even though it's a 1 pixel spacer. Essentially though, getting the image
value won't do you any good in an Image webcontrol because, since the image
is never really opened server-side, the server doesn't actually know the
size of the image. You would have to open it as a bitmap using some of the
System.Drawing classes to really open the image first in order to find the
size.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"karimL" <no************@ligne-bleue-cyber.com> wrote in message
news:40**************@ligne-bleue-cyber.com...
Hi,
how can I retrieve the height and width of
a System.Web.UI.WebControls.Image after populating it's ImageUrl property.
It's seems not to be filled ?
Does someone have a solution ?
Thanks
Karim

Nov 18 '05 #2
If you need the information you can retrieve it by something like

Dim img As System.Drawing.Image
img = System.Drawing.Image.FromFile("blah.jpg")

myWebControlImage.Width = img.Width
myWebControlImage.Height = img.Height

Hope that helps.

-D
"karimL" <no************@ligne-bleue-cyber.com> wrote in message
news:40**************@ligne-bleue-cyber.com...
Hi,
how can I retrieve the height and width of
a System.Web.UI.WebControls.Image after populating it's ImageUrl property.
It's seems not to be filled ?
Does someone have a solution ?
Thanks
Karim

Nov 18 '05 #3
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based
on image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ?.... so I can't use MapPath function to obtain the physical
parth of the picture ... then second question is how to obtain the
physical path from relative path in Design Mode...

Thanks
Karim

"karimL" <no************@ligne-bleue-cyber.com> a écrit dans le message de
news:40**************@ligne-bleue-cyber.com...
Hi,
how can I retrieve the height and width of
a System.Web.UI.WebControls.Image after populating it's ImageUrl property.
It's seems not to be filled ?
Does someone have a solution ?
Thanks
Karim

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
1
by: Ron Vecchi | last post by:
I am using asp.net to upload an image and then perform resizing on it and saving the different sizes to file. The resized images were coming up and being displayed in the bowser fine but the image...
11
by: KarimL | last post by:
Thanks for your advices... but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height. More i just have the url (relative parth) to the...
2
by: Brett Baisley | last post by:
Hello I need help with some ASP.net programming. I have a web page that basically just has the following web components: dropdownlist, listbox and image. I am using VB.net with a CodeBehind...
2
by: sharma | last post by:
Hi, I Have a page which will take authentication from a diffrent page from a difrent website. My program needs to call a page like this from php page lets say:...
2
by: abrtlt | last post by:
I am using Ajax with a PHP script to obtain the name of gif files from a MySQL database. Javascript then embeds the actual file in the web page, thus displaying the image on the fly. For precise...
2
by: Jerry Spence1 | last post by:
I am trying to come up with a focussing routine for a camera and I need to detect when the image is in focus. As I understand it, JPG Image size goes up sharply when it is in focus as it is very...
3
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
1
AaronL
by: AaronL | last post by:
Hello, First I would like to say thank you all for your help in the past. I am stumped again. I am creating an e-commerce system and I want to be able to upload images to the server and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.