Craftx398
Craftx398

Reputation: 339

write image tags inside c# code

This is my code, and I would like to add an image from C# but I am unable to.

defualt.aspx

<li runat="server" id="searchbox">
   </li>

code behind

String name =jack;
String terms = Request["search"];
searchbox.InnerText = "<img src"users/'"+name+"'.png"/>"+ terms; //name and terms is a varible which is storing information from database 

I am a beginner in ASP.NET, so I don't know if this is even possible.

Upvotes: 0

Views: 124

Answers (1)

hardkoded
hardkoded

Reputation: 21705

You have to use InnerHtml instead of InnerText. Also notice that you're missing an = after src

searchbox.InnerHtml = "<img src=\"users/" + name + ".png\"/>"+ terms;

Upvotes: 4

Related Questions