Click here to Skip to main content
12,635,398 members (24,909 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hello,

I want to display image with specific height and width on clicking upload button. I have specified like below but Image is displaying with its original height and width.

Can you please suggest me how can I display image with specified height and width.

<asp:Panel ID="pnlCrop" runat="server" Visible="false" Width="100px" Height="100px">
                       <div id="divImg" style="width: 100px; height: 100px" runat="server">
                           <asp:Image ID="imgCrop" runat="server" />
                       </div>
                       <br />
                   </asp:Panel>


CodeBehind: On clicking upload button

imgCrop.ImageUrl = "~/Images/" + Session["WorkingImage"].ToString();
           imgCrop.Width = "100px";
           imgCrop.Height = "100px";
Posted 22-Dec-12 19:49pm

1 solution

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

Solution 1

imgCrop.ImageUrl = "~/Images/" + Session["WorkingImage"].ToString();
           imgCrop.Width = 100;  // unit measure (100 unit)
           imgCrop.Height = 100; //unit measure (100 unit)
  Permalink  
Comments
bapu_reddy 23-Dec-12 1:00am
   
Hi Rohit, I tried with ur solution but we couldn't get completely. Initially its displaying what we required but its changing to its original size. Can u give another solution. Thanks in advance.
Krunal Rohit 23-Dec-12 1:02am
   
As you've asked to change the height and width, I gave this solution.. Please elaborate your question..
Thanks
bapu_reddy 23-Dec-12 1:04am
   
I can appreciate ur help. While loading the page image is displaying with 100 unit measure( height and width) but after loading the page image is change to its original width and height.
Krunal Rohit 23-Dec-12 1:07am
   
Okay, so what do you want with Image ?
bapu_reddy 23-Dec-12 1:10am
   
Just I want to display image with specified height and width on clicking upload button.
Krunal Rohit 23-Dec-12 1:14am
   
And now what you're getting with given solution ?
bapu_reddy 23-Dec-12 1:16am
   
While loading the page image is displaying with 100 unit measure( height and width) but after loading the page image is change to its original width and height.
Krunal Rohit 23-Dec-12 1:20am
   
http://www.daniweb.com/software-development/pascal-and-delphi/threads/286647/resizing-a-image-in-a-panel

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
Web01 | 2.8.161208.2 | Last Updated 23 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