Search code examples
c#htmlinnerhtmlvisual-web-developer

Replaced InnerHtml Displays as a String


I must be missing the obvious here. I have a drop down menu in a table cell that selects an image to display in that cell after which the drop down menu disappears. I am able to do this with text values in the drop down list by replacing the inner html that holds the drop down list. But when I try to replace the inner html with the location of the image file it just displays as text. Here is the relevant code:

string image = "&ltimg src="" + DropList1.SelectedItem.Value + "" /&gt";
s1.InnerHtml = image;

and the output is:

<img src="D:\Documents and Settings\farmek2\Desktop\Trends\GreenUp.jpeg" />

I need this not to display as text but rather as the image GreenUp.jpg.

Any advice is appreciated.

Regards.


Solution

  • Send the actual markup, not the encoded string.

    string image = "<img src=\"" + DropList1.SelectedItem.Value + "\" />";