ASP.NET force image size in image control

Hi Experts, is there a way to force the size of an image? I have an image control with dimensions (200px x 100px) set but when I load a bigger (dimensions e.g. 350px x 100px) image into it - it extends.
David CIT Projects ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russ SuterSenior Software DeveloperCommented:
You could add css style properties (or a css class) to the image control. The ASPX markup and css class might look like this:

<asp:Image ID="myImage" runat="server" CssClass="constrained" ImageUrl="~/images/myImage.gif" />

  width: auto;
  height: auto;
  max-width: 200px;
  max-height: 100px;

Open in new window

David CIT Projects ManagerAuthor Commented:
Thanks Russ! That seems to be working fine in the browser but Outlook is. See attached image. Any ideas why?
Outlook v Browser
Russ SuterSenior Software DeveloperCommented:
If you're going the css route you'd need to embed the css into the document. Even then Outlook might ignore it. You can try adding the style directly in your codebehind.

  myImage.Attributes.Add("style", "width: auto; height: auto; max-width: 200px; max-height: 100px;");

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David CIT Projects ManagerAuthor Commented:
I tried the code behind but its still looking the same
Russ SuterSenior Software DeveloperCommented:
They style is valid, it's just being ignored by Outlook.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.