Programmatically added Image webpart

Joined
Jun 5, 2008
Messages
1
Reaction score
0
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 =)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top