The Label control in ASP.NET seems to render Sure, I coul
tags, but is there a server control to render HTML within a
I think you need HtmlGenericControl class. It has a constructor which accepts a string variable which initializes a new instance of the HtmlGenericControl
class with the specified tag:
var div = new HtmlGenericControl("div");
It is also has InnerHtml
and InnerText
properties (you mentioned this in a comment to the previous answer).
Try the Panel control.
Try this:
<div class="myclass">
<asp:Literal ID="mytext" runat="server"></asp:Literal>
</div>
Set your text inside Literal
, which renders without html tag
Of course: ASP.NET has a built-in control called Panel!
And you may use it as follows:
<asp:Panel ID="myPanel" runat="server">
<!-- Other markup here like client and server controls/elements -->
</asp:Panel>