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

发布于 2024-08-16 08:59:32 字数 99 浏览 6 评论 0原文

例如,当前,该值通过 lblAmount.Text = Amount & 设置。 " €"

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

For example currently, the value is set with lblAmount.Text = Amount & " €"

How can i add (dynamically) superscript to the sign?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紅太極 2024-08-23 08:59:32

使用 SUP 标签。

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

use the SUP tag.

lblAmount.Text = Amount & "<sup>€</sup>"
_蜘蛛 2024-08-23 08:59:32

您可以通过添加样式属性或添加类(并在样式标记或 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>"

You do this best by adding either a style attribute or by adding a class (and adding the style in a style tag or a css file.

<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; 
}

or

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

and this, in your code file

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

You could also use the html equivalent sup:

Me. lblAmount.Text = Amount & " <sup>€</sup>"
翻了热茶 2024-08-23 08:59:32
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.
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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文