Click here to Skip to main content
15,920,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a label like this in a page.
when you run the page the label is displayed as Test and every thing after that is not displayed. Please help me with a solution.

<body>
    <form id="form1" runat="server">
    <div>
        <asp:label id="Label1" runat="server" text="Test"></asp:label>
    </div>
    </form>
</body>


Actually posting a question itself is a issue here.

[edit] edited for more readability [/edit]
Posted
Updated 3-Aug-10 8:07am
v5
Comments
Lima3 3-Aug-10 14:06pm    
<asp:label id="Label1" runat="server" text="Test <Claim>">
Yusuf 3-Aug-10 14:06pm    
What makes you say "Actually posting a question itself is a issue here."?
Lima3 3-Aug-10 14:07pm    
I meant posting my question here since any thing in < and > will treated as html decoded

You may have to escape the <> brackets inside the string.
 
Share this answer
 
Comments
Lima3 3-Aug-10 13:45pm    
Hey can you tell me how can I do that ....
you must use html encodings like is done on this site as well.

The value should then be "Test &lt;Claim&gt;"

Otherwise it is translated as non existent html element and therefore discarded.

Good luck!
 
Share this answer
 
Comments
Lima3 3-Aug-10 13:49pm    
The problem is the data is coming form the migrated data and so we don't have control of it. Its not just one label.
E.F. Nijboer 3-Aug-10 13:55pm    
You should actually encode it using provided function Server.HtmlEncode
http://msdn.microsoft.com/en-us/library/a2a4yykt.aspx
http://www.devasp.net/net/articles/display/279.html
You could also create your own control that will do this automatically or maybe something already did ;-)
In the code Behind use this

string s = "test <test2>";
Label1.Text = Server.HtmlEncode(s);
 
Share this answer
 
Comments
AspDotNetDev 4-Aug-10 18:14pm    
I think that will double encode the text. IIRC, labels automatically HTML encode the text property. So, if you encode it first, it will be double encoded.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900