|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Create image web control adapterI 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 Chris,
You may find some success with the CSS Control Adapters. http://www.asp.net/cssadapters/ Scott Guthrie explains them here. They are quite powerful. http://weblogs.asp.net/scottgu/archive/2006/05/02/CSS-Control-Adapter-Toolkit-for-ASP.NET-2.0-.aspx Brennan Stehling http://brennan.offwhite.net/blog/ hardi***@hotmail.com wrote: Show quoteHide quote > 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
How to change the font style and size on the entire Aspx page programatically
how to use Click event with programmatically defined button? Ajax Triggers for DropDownList don't fire Newbie Question: How Does One Access an Individual Field in a Record? Embeding html controls in Server Control Generating the *.aspx.designer.vb Files Regular Expression Validator question Menu can't refresh Validation of RadioButtonList Menu question (list menu) |
|||||||||||||||||||||||