I have below label in my aspx page,
<asp:Label ID="lblMessage" runat="server" CssClass="msg"></asp:Label>
When it renders on page, it creates <span>...</span>
Is there anyway, not to generate this span tag?
I have below label in my aspx page,
<asp:Label ID="lblMessage" runat="server" CssClass="msg"></asp:Label>
When it renders on page, it creates <span>...</span>
Is there anyway, not to generate this span tag?
You could use a literal HTML <label>
element:
<label id="lblMessage" runat="server" class="msg">...</label>
Because of the runat="server"
you can still access it through the id
in the code-behind .cs
file.
The asp:Label
control will always create a <span>
in this case.
If you want it to not create a span you could use a literal. Lets say you wanted it to be in a div instead you could do this.
<div class="msg"><asp:Literal id="lblMessage" runat="server" /></div>
The literal just outputs the string without any html tags around it.