Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

XML
<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

C#
imgCrop.ImageUrl = "~/Images/" + Session["WorkingImage"].ToString();
           imgCrop.Width = "100px";
           imgCrop.Height = "100px";
Posted

1 solution

C#
imgCrop.ImageUrl = "~/Images/" + Session["WorkingImage"].ToString();
           imgCrop.Width = 100;  // unit measure (100 unit)
           imgCrop.Height = 100; //unit measure (100 unit)
 
Share this answer
 
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.
[no name] 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.
[no name] 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.

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