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

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

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

Me.ImageUrl="myurlstring"
MyBase.RenderContents(writer)

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.
 
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!
 
Back
Top