Setting Image Width/Height in codebehind - ASP.NET, C# -


I am trying to determine the width and height of images in a dentist in codebehind.

This plan has to do some complex work based on the width / height, so setting the width and height of 50% in the ASPX file is not an option.

For some reasons I always get 0 for width and height. Image1.ImageUrl, though what do I expect any thoughts? Image system Web. UI. Vaibong Image is not a system. Drawing Image.

  Secure zero data list 9_item data bound (object sender, data list event ARG E) {image image 1 = (image) e. Item.FindControl ("Image1"); Double height = image 1. height. value; Double width = image1.Width.Value; Height = height * 0.5; Width = width * 0.5; Image 1 Het = new unit (height); Image1.Width = new unit (width); }  

Remember with a img tag, default Do not set width and height in this case, unless you do not set the width and height , They will be 0 (or undefined). If you need the actual (image, pixels) width and height, then you have to find out that by loading the image into memory,

Depending on the file type, perhaps a decoder in .NET or the ability to load it in advance, load it into bitmap and ask the width and height there.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -