Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Programmatically added Image webpart

Reply
Thread Tools

Programmatically added Image webpart

 
 
ngjiaxun ngjiaxun is offline
Junior Member
Join Date: Jun 2008
Posts: 1
 
      06-05-2008
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 =)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET 1.1 WebPart to .NET 2.0 WebPart anars ASP .Net 0 01-07-2007 07:31 PM
Programmatically adding a WebPart to a content page kjartan93a@yahoo.com ASP .Net 1 03-22-2006 10:36 PM
Persisting Programmatically Added WebParts Imran ASP .Net 3 03-08-2006 08:18 AM
Modifying a programmatically added field after PostBack Nomen Nescio ASP .Net 2 06-28-2005 02:47 PM
how do I access control I added programmatically? RN ASP .Net 4 02-16-2005 05:48 PM



Advertisments