Using ASP.Net, I have a server control for which i would like to add the inline css style “background-image:none”. However, when i call:
writer.AddStyleAttribute("background-image", "none");
The following inline style is generated (and tries to resolve the url “none”):
background-image:url(none)
Is there a special syntax I can use to set the background image to none inline?
Looking at the code for the
HTMLTextWriterandCssTextWriterclasses in .NET Reflector, the only thing I can think of is subclassingHTMLTextWriteryourself.“Binary not the first element in the style enum”,
~HtmlTextWriterStyle.BackgroundColor, is what it uses for any style whose name it doesn’t recognize, and therefore doesn’t bother to check if the value needs wrapped in “url()” when it’s actually written out.HtmlTextWriterExisn’t the greatest name, but whatever. Depending on what you’re doing, you might(?) need to do something like this in your code-behindSystem.Web.UI.Pagesubclass:And here’s the class: