tags:

views:

127

answers:

2
protected void Button1_Click(object sender, EventArgs e)
{
string a;
a = "vimal < kumar>";        
Label1.Text = a;
}

Output:

vimal

Tag( <ABCDE> ) inner text why not displayed in label box (ASP.NET),

Actual result is vimal <kumar> but the vimal only displayed, tag inner text not displayed

A: 

Because < and > together are HTML Tags. You'll need to use their ascii representations if you don't want them to be hidden.

George Stocker
+2  A: 

you must use the html encoded variant of the string. HtmlEncode will do the trick.

(there is also UrlEncode for encoding Url's)

 Dim test = "This is an <little>test</little>"
 test = HttpUtility.HtmlEncode(test)
Alex