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

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.
 
N

Nathan Sokalski

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!
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top