Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RenderContents not rendering programmatically set attributes inherited from System.Web.UI.WebControls.Image

Reply
Thread Tools

RenderContents not rendering programmatically set attributes inherited from System.Web.UI.WebControls.Image

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      07-30-2009
I have a custom control that inherits from System.Web.UI.WebControls.Image.
When overriding the RenderContents method, I include the following lines of
code:

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

However, when I run the control, it renders the following:

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

Notice that the "src" attribute has an empty string as it's value. However,
when I ran the debugger, it showed that the specified value did get assigned
to Me.ImageUrl, so I would expect it to render:

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

I have tried this same test with other properties such as AlternateText, and
the same thing happened (they did not render). However, I once wrote a
custom control that inherited System.Web.UI.WebControls.DropDownList in
which I override RenderContents the same way (I set an inherited property
using Me.Property=Value and then call MyBase.RenderContents(writer)), and
that worked fine. Why is it not working here? Any help would be appreciated.
Thanks.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      07-31-2009
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
(E-Mail Removed)
http://www.nathansokalski.com/

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a custom control that inherits from System.Web.UI.WebControls.Image.
>When overriding the RenderContents method, I include the following lines of
>code:
>
> Me.ImageUrl="myurlstring"
> MyBase.RenderContents(writer)
>
> However, when I run the control, it renders the following:
>
> <img src="" style="border-width:0px;" />
>
> Notice that the "src" attribute has an empty string as it's value.
> However, when I ran the debugger, it showed that the specified value did
> get assigned to Me.ImageUrl, so I would expect it to render:
>
> <img src="myurlstring" style="border-width:0px;" />
>
> I have tried this same test with other properties such as AlternateText,
> and the same thing happened (they did not render). However, I once wrote a
> custom control that inherited System.Web.UI.WebControls.DropDownList in
> which I override RenderContents the same way (I set an inherited property
> using Me.Property=Value and then call MyBase.RenderContents(writer)), and
> that worked fine. Why is it not working here? Any help would be
> appreciated. Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
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
Render vs RenderContents Alex Nitulescu ASP .Net 2 08-17-2009 08:46 AM
Inheriting System.Web.UI.WebControls.Image and RenderContents Nathan Sokalski ASP .Net 1 07-31-2009 04:44 AM
RenderContents not rendering programmatically set attributes inherited from System.Web.UI.WebControls.Image Nathan Sokalski ASP .Net Web Controls 1 07-31-2009 04:44 AM
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
RenderContents Doug Holland ASP .Net Building Controls 0 09-17-2004 06:27 PM



Advertisments