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

ASP.NET如何将上标添加到标签控件中?,asp.net,vb.net,formatting,label,superscript,Asp.net,Vb.net,Formatting,Label,Superscript,例如,当前该值设置为lblAmount.Text=Amount&“€” 如何将上标(动态)添加到€符号?使用SUP标签 lblAmount.Text = Amount & "<sup>€</sup>" lblAmount.Text=金额和“€” 通过添加样式属性或添加类(并在样式标记或css文件中添加样式),您可以做到最好 <asp:Label id="lblAmount" runat="server"></asp:Label><a

例如,当前该值设置为
lblAmount.Text=Amount&“€”

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

使用SUP标签

lblAmount.Text = Amount & "<sup>€</sup>"
lblAmount.Text=金额和“€”

通过添加样式属性或添加类(并在样式标记或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; 
}
您还可以使用html等效的sup:

Me. lblAmount.Text = Amount & " <sup>€</sup>"
Me.lblAmount.Text=金额和“€”

注意:我刚刚在一个客户站点上遇到了一个问题,使用这种方法,IE8在到达此页面时完全崩溃。我能够在开发站点上重现相同的行为,但只有在IETester中(甚至我的IE8虚拟机都不能重现,IE与客户站点的版本相同)移除
标签解决了这个问题。我仍然很困惑,因为在其他地方都无法产生相同的问题…小心!
Me. lblAmount.Style.Add(HtmlTextWriterStyle.FontSize, "9px")
Me. lblAmount.Style.Add(HtmlTextWriterStyle.VerticalAlign, "top")
Me. lblAmount.Text = Amount & " <sup>€</sup>"
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.