|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
I do I remove the style attribute from Image controls?A number of controls which use images seem to render html with a default style attribute: style="border-width:0px;" e.g. <input type="image" name="ctl00$Main$ImageButton1" id="ctl00_Main_ImageButton1" src="images/address_book.gif" style="border-width:0px;" /> <img id="ctl00_Main_Image1" src="images/delete.gif" style="border-width:0px;" /> I'd like to remove it from all of these controls because it's a waste of mark-up and we use external stylesheets to style web pages. I've tried things like this in the Load and PreRender page events but the style refuses to disappear. ImageButton1.Style.Clear(); ImageButton1.Style.Remove.("border-width"); Any suggestions? Thanks Andrew Not an answer, but just to let you know that we ran into a similar problem
with the GridView and haven't yet found a way to remove it. That attribute seems to be hardwired in. Show quoteHide quote "J055" <j055@newsgroups.nospam> wrote in message news:OeANjcYWGHA.2476@TK2MSFTNGP05.phx.gbl... > Hi > > A number of controls which use images seem to render html with a default > style attribute: style="border-width:0px;" > > e.g. > > <input type="image" name="ctl00$Main$ImageButton1" > id="ctl00_Main_ImageButton1" src="images/address_book.gif" > style="border-width:0px;" /> > > <img id="ctl00_Main_Image1" src="images/delete.gif" > style="border-width:0px;" /> > > > I'd like to remove it from all of these controls because it's a waste of > mark-up and we use external stylesheets to style web pages. > > I've tried things like this in the Load and PreRender page events but the > style refuses to disappear. > > ImageButton1.Style.Clear(); > ImageButton1.Style.Remove.("border-width"); > > Any suggestions? > > Thanks > Andrew > > > > Hi
Thanks for the response. Looks like you're right about hardwiring. Using the Reflector tool to disassemble the Image control I found it contained an AddAttributesToRender method with this code tucked in at the bottom: if (this.BorderWidth.IsEmpty) { if (base.EnableLegacyRendering) { writer.AddAttribute(HtmlTextWriterAttribute.Border, "0", false); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px"); } } I'm sorry Microsoft but that is just plain wrong! Andrew Hi Andrew,
Yes, it is a bit dummy that the style is hard coded. Currently what I can get is using the html image server control instead or creating a custom control to render the clear image element. Regards, Steven Cheng Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Other interesting topics
RE: Checkbox data binding on Checked property
Accessing FormView template controls validating user control Link to download a file. .NET 2.0 TreeView control vertical align problem How to reach the object connected to repeater Dynamically move control. dynamic controls Passing data into a custom control Please help ..... GridView |
|||||||||||||||||||||||