MRWonderFuXker
MRWonderFuXker

Reputation: 203

How to write html string to a asp Lable which is showing as text instend of HTML object?

I want to show some html string in text in my asp web, however it is creating some html object.

mylab.Text = "<br/>";

Upvotes: 1

Views: 2178

Answers (1)

AT-2017
AT-2017

Reputation: 3149

You can do the following easily:

Default.aspx:

<asp:Label ID="Label1" runat="server"></asp:Label>

Finally do the following:

Default.aspx.cs:

Label1.Text = Server.HtmlEncode("<title>ASP.NET Tutorial - Label Display HTML</title><br/>");

For more, see this: Display HTML Tags in an ASP.NET Label

Upvotes: 1

Related Questions