質問

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.

役に立ちましたか?

解決

Send the actual markup, not the encoded string.

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

他のヒント

This is more thank likely because you are injecting HTML special characters into an HTML page. Rather than being rendered as HTML, a browser converts it in the corresponding symbol. Use the actual characters and not their special character equivalents.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top