Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to display the image in image control where the image consit of any size I need to fit the particular file in the image control.

For example:

Upload a photo[textbok]
Load Image



___________________
| |
| |
| |
| |
| Image |
| |
| |
| |
| |
___________________


When we click on the load image what ever the size of image would be it need to display in the image control property.
Posted

1 solution

Use a PictureBox control for displaying the image. For the size of the image you can PictureBox's SizeMode[^] property.

Normal: The image is placed in the upper-left corner of the PictureBox. The image is clipped if it is larger than the PictureBox it is contained in.

StretchImage: The image within the PictureBox is stretched or shrunk to fit the size of the PictureBox.

AutoSize: The PictureBox is sized equal to the size of the image that it contains.

CenterImage: The image is displayed in the center if the PictureBox is larger than the image. If the image is larger than the PictureBox, the picture is placed in the center of the PictureBox and the outside edges are clipped.

Zoom: The size of the image is increased or decreased maintaining the size ratio.

Good luck,
OI
 
Share this answer
 
Comments
Mannava Siva Aditya 4-Dec-12 8:18am    
We dont have a picture box in asp.net? We have it in C# but i m trying to implement it in asp.net so need to take only image or need to look on some other logic!
Orcun Iyigun 4-Dec-12 9:54am    
Sorry for misleading you. Then you can set it your self when the button is clicked.
Image.Width = x;
Image.Height = y;
Mannava Siva Aditya 5-Dec-12 0:48am    
I want to set the image size not the image control because if we set the control with width and height then all pics might not be allowed. So I want all the images set in the same control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900