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 7278247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:50:55+00:00 2026-05-28T22:50:55+00:00

This is my code : string myText = Wählen Sie bitte; string myTextDecoded =

  • 0

This is my code :

string myText = "Wählen Sie bitte";
string myTextDecoded = HttpUtility.HtmlDecode(myText);
Response.Write(myTextDecoded);
ddAdulti.Items.Add(new ListItem(myTextDecoded, ""));

in first case (Response.Write) it prints, on my html document :

Wählen Sie bitte

which is correct! But on the select box’s option it prints, on my html document :

Wählen Sie bitte

which is wrong (I’ve decode it…with the same function).

Why this behaviour?

  • 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-28T22:50:56+00:00Added an answer on May 28, 2026 at 10:50 pm

    Based on your updated question, I’m going to make a potentially incorrect assumption about your understanding.

    I’m guessing that you’re looking at the HTML source and not understanding why the string is encoded in one place and unencoded in the other. The explanation is rather straightforward: server-side controls automatically encode their content while Response.Write writes raw output. There’s a reason for this: server side controls often contain user input which is inherently unsafe, so it’s automatically encoded to prevent cross-site scripting attacks, or in the less nefarious cases, user input merely breaking your page.

    By way of example, imagine if the list didn’t encode the content and you did this:

    ddAdulti.Items.Add(new ListItem("</select>", ""));
    ddAdulti.Items.Add(new ListItem("An actual valid value", ""));
    

    The net result would be that your markup would look something like this:

    <select>
        <option></select></option>
        <option>An actual valid value</option>
    </select>
    

    As you can see, that’s clearly broken. What you end up with depends on the interpreting browser, but is most likely an empty dropdown list.

    Now, since the controls do encode their content, the markup ends up being:

    <select>
        <option>&lt;/select&gt;</option>
        <option>An actual valid value</option>
    </select>
    

    and things work out nicely. 🙂

    [edit]

    It occurs to me that from my example, it’s probably not clear why you’re seeing the behavior with a character like ‘ä’. That’s because many character encodings don’t support umlauted letters, so for the control writers, it’s probably easiest to simply encode all characters outside the 7-bit ASCII character set. 🙂

    [edit 2]

    It’s becoming clear to me that the original post doesn’t actually describe the real problem. Apparently, what markzzz is trying to do is fetch unencoded HTML from the database and display it as-is for the client. There already exists a WebForms control for doing this: LiteralControl. It will display whatever you stick in it, unencoded.

    That said, there is no way that I know to embed that inside a DropDownList — see my explanation of how the rendered HTML would break. However, if you merely want to display a list of items, but not necessarily a dropdown list, you can use a LiteralControl inside a Repeater or some such.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];
I have written this code to convert string in such format 0(532) 222 22
Just curious how you would comment this line of code: string customerNm = customerNm.EndsWith(s)
This code: System.out.println(String.format(%f, Math.PI)); System.out.println(Math.PI); produces that result on my computer: 3,141593 3.141592653589793 Why
This code compiles: private static void Main(string[] args) { bool? fred = true; if
This code works: class Test { public: Test(string name) : _name(name) {}; bool operator()()
This code basically translates characters based on position in one string to the character
this code is correct?? String note = text.txt; FileWriter file = new FileWriter(note); Scanner
Given this code: var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); });
I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New

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.