Inheriting System.Web.UI.WebControls.Image and RenderContents

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jul 29, 2009.

  1. I have a custom control that inherits System.Web.UI.WebControls.Image. When
    overriding the RenderContents method, I have the following two lines of


    When I run the control, it renders the following:

    <img src="" style="border-width:0px;" />

    Why is it not rendering the ImageUrl? I did a debug, and the value is being
    correctly assigned to Me.ImageUrl, but it still renders an empty src
    attribute. Any ideas? Thanks.
    Nathan Sokalski, Jul 29, 2009
    1. Advertisements

  2. I found my problem. I probably should have realized this sooner (since it's
    something I already knew), but it was simply the fact that the attributes in
    the actual tag are rendered in the Render method, and RenderContents is only
    for children and stuff between the opening and closing tags. Problem Solved!
    Nathan Sokalski, Jul 31, 2009
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.