Set an image size C#

Posted on 2012-08-18
Last Modified: 2012-08-18
I have a method that loads an image in my SharePoint user control.  I need to make the image stretch to fit the container.  Currently the image is too small.  I have tried this with in-line css and a style sheet.  Neither work. Is there an easy way to set the size of the image in C# to something like (width: 100%; height: 50px) ?  Here is what I have so far:
 public override void RenderControl(HtmlTextWriter writer)
            imgLogo.ImageUrl = SPContext.Current.Site.Url + "/_layouts/images/Custom/PosterLogo.png";

Open in new window

<td colspan="4">
            <asp:Image ID="imgLogo" runat="server" CssClass="posterLogo" AlternateText="Logo" />  

Open in new window

Question by:Christopher Gore
    LVL 18

    Accepted Solution

    try this
    imgLogo.Height = 200;
    imgLogo.Width = 200;

    Open in new window

    LVL 1

    Author Closing Comment

    by:Christopher Gore

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now