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
    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.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Jul 29, 2009
    #1
    1. Advertising

  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

    http://www.nathansokalski.com/
    "Nathan Sokalski" <> wrote in message
    news:%...
    >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.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    Nathan Sokalski, Jul 31, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. byrd48
    Replies:
    0
    Views:
    3,562
    byrd48
    Jul 6, 2006
  2. Nathan Sokalski
    Replies:
    1
    Views:
    533
    Nathan Sokalski
    Jul 31, 2009
  3. Nathan Sokalski
    Replies:
    1
    Views:
    1,336
    Nathan Sokalski
    Jul 31, 2009
  4. Jimmy [Used-Disks]

    Inheriting from System.Web.UI.WebControls.Table

    Jimmy [Used-Disks], Aug 14, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    218
    Jimmy [Used-Disks]
    Aug 14, 2003
  5. Nathan Sokalski
    Replies:
    1
    Views:
    1,012
    Nathan Sokalski
    Jul 31, 2009
Loading...

Share This Page