I derive the controllers from a base class:
namespace merawi.Controllers
{
public class BaseController : Controller
{
public CultureInfo trTR = new CultureInfo("tr-TR");
public BaseController()
{
trTR.NumberFormat.CurrencySymbol = "TL";
}
}
}
and use this statement to format the currencies:
ViewBag.SellingPrice = sp.ToString("C", trTR);
However, in the views which has viewmodels like
@model List<merawi.Models.DocumentWorkStep>
I need a way to format the currencies as desired.
SellingPrice
is a decimal field in the DocumentWorkStep
class:
public Nullable<decimal> SellingPrice { get; set; }
and using this
<td>@string.Format("{0:C}", res.SellingPrice)</td>
outputs ₺, I need "TL"
I need a way to access the trTR object from the view files...
Thanks
Add this to your web.config file, assuming that you want the same culture to be used in your entire application:
In my case, I add the globalization tag in the web.config file, also, since we need to customize the culture format(such as using
"."
instead of","
as decimal inFR-CA
), I add a customization in Global.asax.vb, which can set the globalization globally.Web.config:
Global.asax.vb:
That's my case. Hopefully it helps. Thank you.