Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:07:57+00:00 2026-05-14T03:07:57+00:00

Using ASP.Net, I have a server control for which i would like to add

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:07:57+00:00Added an answer on May 14, 2026 at 3:07 am

    Looking at the code for the HTMLTextWriter and CssTextWriter classes in .NET Reflector, the only thing I can think of is subclassing HTMLTextWriter yourself.

    “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.

    HtmlTextWriterEx isn’t the greatest name, but whatever. Depending on what you’re doing, you might(?) need to do something like this in your code-behind System.Web.UI.Page subclass:

    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlTextWriterEx(writer);
    }
    

    And here’s the class:

    class HtmlTextWriterEx : HtmlTextWriter
    {
        public HtmlTextWriterEx(TextWriter writer) 
            : this(writer, "\t")
        {
        }
    
        public HtmlTextWriterEx(TextWriter writer, string tabString)
            : base(writer, tabString)
        {
    
        }
    
        public override void AddStyleAttribute(string name, string value)
        {
            if (name.ToLower() == "background-image" && value.ToLower() == "none")
                base.AddStyleAttribute(name, value, ~HtmlTextWriterStyle.BackgroundColor);
            else
                base.AddStyleAttribute(name, value);
        }
    
        public override void AddStyleAttribute(HtmlTextWriterStyle key, string value)
        {
            if(key == HtmlTextWriterStyle.BackgroundImage && value.ToLower() == "none")
                base.AddStyleAttribute("background-image", value, ~HtmlTextWriterStyle.BackgroundColor);
            else
                base.AddStyleAttribute(key, value);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a control application - using asp.net webservices. I have a timer which
I have a site developed in ASP.NET and hosted on a windows server using
Greeting, if I have asp.net checkboxlist control : <asp:CheckBoxList id=list1 runat=server> <asp:ListItem>One</asp:ListItem> <asp:ListItem>Two</asp:ListItem> <asp:ListItem>Three</asp:ListItem>
I have the following jQuery that does find the ASP.NET server control (tested by
I'm using asp.net/c# and have a number of Collapsible Panel Extenders that have been
I am in the start up of a project using ASP.NET MVC and have
Using asp.net, I need to generate a snapshot of an youtube video. I have
I have been using ASP.NET for years, but I can never remember when using
I am using ASP.NET Dynamic Data for a project and I have a table
I am using asp.net MVC to develop an application that will have ajax interactions.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.