Programmatically added Image webpart

Discussion in '.NET' started by ngjiaxun, Jun 5, 2008.

  1. ngjiaxun

    ngjiaxun

    Joined:
    Jun 5, 2008
    Messages:
    1
    Hi,

    I tried this with both Image and HtmlImage but the image just doesn't display.





    protected void Page_Load(object sender, EventArgs e)
    {
    WebPartManager wpManager = WebPartManager.GetCurrentWebPartManager(this);

    ...

    HtmlImage img = new HtmlImage();
    img.Src = ResolveUrl("~/Images/Dilbert.gif");
    img.ID = "Dilbert";
    img.Attributes["title"] = "Dilbert";


    wpManager.AddWebPart(wpManager.CreateWebPart(img), PageWPZone, 1);
    }




    When I view source in the browser, I find that the src attribute of the img is empty. This doesn't happen if I drag and drop the image in the web part zone in VWD. It only happens if I programmatically add images to the zone.

    Any help is appreciated. Thanks =)
     
    ngjiaxun, Jun 5, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    516
    John M Deal
    Nov 8, 2004
  2. RN
    Replies:
    4
    Views:
    856
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 16, 2005
  3. Nomen Nescio
    Replies:
    2
    Views:
    2,066
    Sean M
    Jun 28, 2005
  4. kjartan93a@yahoo.com

    Programmatically adding a WebPart to a content page

    kjartan93a@yahoo.com, Mar 22, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,369
    =?Utf-8?B?RFdT?=
    Mar 22, 2006
  5. anars
    Replies:
    0
    Views:
    367
    anars
    Jan 7, 2007
Loading...

Share This Page