当调用以下命令时,我添加了一个标签扩展名以添加货币符号:
@Html.Label("curr", string.Empty, Model.Company.Currency) 39.00
我用参数调用它,例如:USD
但是,当我在屏幕上查看页面时,它显示:
<label for=''>$</label> 39.00
如何让它仅将货币符号显示为标签?
谢谢,
标记
Helpers/LabelExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace inv5.Helpers
{
public static class LabelExtensions
{
public static string Label(this HtmlHelper helper, string str, string target, string ccode)
{
String ret = "";
switch (ccode)
{
case "GBP": ret = "£"; break;
case "AUD": ret = "$"; break;
case "BRL": ret = "R$"; break;
case "CAD": ret = "$"; break;
case "CZK": ret = ""; break;
case "DKK": ret = ""; break;
case "EUR": ret = "€"; break;
case "HKD": ret = "$"; break;
case "HUF": ret = ""; break;
case "ILS": ret = "₪"; break;
case "JPY": ret = "¥"; break;
case "MXN": ret = "$"; break;
case "TWD": ret = "NT$"; break;
case "NZD": ret = "$"; break;
case "NOK": ret = ""; break;
case "PHP": ret = "P"; break;
case "PLN": ret = ""; break;
case "SGD": ret = "$"; break;
case "SEK": ret = ""; break;
case "CHF": ret = ""; break;
case "THB": ret = "฿"; break;
case "USD": ret = "$"; break;
default:
ret = "";
break;
}
return String.Format("<label for='{0}'>{1}</label>", target, ret);
}
}
}