Click here to Skip to main content
12,633,519 members (32,918 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 4-Dec-12 3:05am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100