Auto Html Encoding - I'd like to really use the & character, can I disable .net auto encode?

Posted on 2006-04-18
Last Modified: 2010-06-21
I have some code as such:

DropDown.Items.Add(new ListItem("text before space     text after space", ""));

I'd like to use the none breaking spaces but .net automatically encodes the ampersand characters. Is there a way around this auto encoding?

Question by:brooklynDev
    LVL 3

    Assisted Solution

    Try this:

    DropDown.Items.Add(new ListItem(@"text before space     text after space", ""));

    that might get rid of the '&' characters being displayed.
    LVL 33

    Accepted Solution

    Try something like this, you just need to use another character,

    string padding = "\xA0\xA0";
    ddlItems.Add(new ListItem(padding + "Hello World","123"));

    Author Comment

    My deepest and most sincere apologies for letting this question go unattended. There were extenuating circumstances but I will make sure it never happens again.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now