划掉文字文本

时间:2011-10-12 14:30:00

标签: c# asp.net

这可能是一个非常新手的问题,但是我找不到怎么做,我有一个显示数字4.00的文字,我想要做的就是在你身上加上一条线就像当你抓一些东西,因为它是错的。我这样做是因为我需要将其更新为新价格,但显示旧的价格,如

old 16.00 (with a line through)  new 14.95 (normal). 

这是我的,但不知道如何实现?这有可能吗?

 string myPrice = "16.00";
 litMyPrice.Text = myPrice.ToString("c") 

5 个答案:

答案 0 :(得分:7)

您需要使用asp:Label代替<span>生成litMyPrice.Attributes.Add("style", "text-decoration: line-through;"); 代码才能设置样式:

CssClass

创建一个CSS类并更改.strikethrough {text-decoration: line-through;} litMyPrice.CssClass = "strikethrough"; 属性,我推荐这种方法。混合标记和CSS甚至.NET生成的样式可能会让您感到痛苦。

{{1}}

答案 1 :(得分:1)

litMyPrice.Text = String.Format("<del>{0}</del>", myPrice.ToString("c"));

答案 2 :(得分:1)

<del>16.00</del>

15.00 现在16.00

答案 3 :(得分:0)

将CssClass分配给文字,并使用text-decoration:line-through。

对其进行样式设置

答案 4 :(得分:0)

我认为litMyPrice是你UI上的一个控件。如果它是一个asp标签,你应该可以设置

<asp:Label ... Font-Strikeout="true" />