Create image web control adapter

H

hardieca

Hi,

I would like to create an adapter for the image web control to cure a
pet peeve of mine. Currently, if I write out:

<asp:Image ImageUrl="myPic.jpg" AlternateText="Some text"
runat="server" />

the html that is emitted is:

<img src="myPic.jpg" alt="Some text" style="border-width:0px" />

I would like that inline style struck out completely for every image on
my site. As it turns out, in the System.Web.UI.WebControls.Image class
resides the AddAttributesToRender method. At the very bottom in an IF
statement, the following:

else
{
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
}

I think creating a custom adapter would be the most elegant solution,
but I'm unsure as to how to tackle this. It's my understanding that the
adapter replaces the control's rendering logic, but at the end of the
day I only want to edit an IF statement. I don't want to have to
re-invent the wheel to replace the System.Web.UI.WebControls.Image and
System.Web.UI.WebControls.WebControl classes rendering logic. Is there
a simple way to achieve this?

Kind regards,

Chris
 

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

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top