ASP.NET如何将上标添加到标签控件中?

时间:2010-01-01 20:33:57

标签: asp.net vb.net formatting label superscript

例如,目前,该值设置为lblAmount.Text = Amount & " €"

如何将(动态)上标添加到符号?

3 个答案:

答案 0 :(得分:3)

使用SUP标签。

lblAmount.Text = Amount & "<sup>€</sup>"

答案 1 :(得分:1)

您可以通过添加样式属性或添加类(并在样式标记或css文件中添加样式)来做到最好。

<asp:Label id="lblAmount" runat="server"></asp:Label><asp:Label id="lblAmountSymbol" runat="server" CssClass="yourclass"></asp:Label>

span.yourclass {
    font-size:9px; 
    vertical-align:top; 
}

<asp:Label id="lblAmount" runat="server"></asp:Label><asp:Label id="lblAmountSymbol" runat="server"></asp:Label>

这就是你的代码文件

Me. lblAmount.Style.Add(HtmlTextWriterStyle.FontSize, "9px")
Me. lblAmount.Style.Add(HtmlTextWriterStyle.VerticalAlign, "top")

你也可以使用html等效的sup:

Me. lblAmount.Text = Amount & " <sup>€</sup>"

答案 2 :(得分:0)

Goto Start->Programs->Accessories->System tools->Character Map
Now select this Character ² from the Characters listed.
Click Select
Click Copy

Then try to change the text of any control by pasting this Character in the Lable or Button Caption at Properties.

Even you can wrting code also like this:
Code\Button1.Text = "mm ²"\Code

This is working fine with me.