- Home
- Forum
- ASP.NET MVC - EJ 2
- NumericTextBox Currency property
NumericTextBox Currency property
Hello, 
I'm testing theNumericTextBox and I want to assign the currency dynamically.
The currency is not locale dependent and there may be multiple inputs with different currencies at the same time, so setting locale is not suitable.
I tried to use the Currency property, but no currency string nor symbol is displays.
I could probably do it with js, but using standard property is the preferred way for me.
Is there something wrong with my code?
@Html.LabelFor(model => model.PriceChange, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EJS().NumericTextBoxFor(model => model.PriceChange).Format("c2").Currency("EUR").CssClass("").Render()
@Html.ValidationMessageFor(model => model.PriceChange, "", new { @class = "text-danger" })
Any advice would be greatly appreciated!
SIGN IN To post a reply.
5 Replies
PM
Ponmani Murugaiyan
Syncfusion Team
April 2, 2021 02:29 AM UTC
Hi Petr,
Greetings from Syncfusion support.
We checked your reported query. We would like to know you that, the culture is not necessary to load the corresponding currency symbol. You can achieve using the currency property. Please find the ensured sample with your provided code snippet below for reference.
[Index.cshtml]
|
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<div class="col-lg-12 control-section">
<div id="wrapper">
@Html.EJS().NumericTextBoxFor(model => model.value).Width("200px").Format("c2").Currency("EUR").Render()
<div>
@Html.ValidationMessageFor(model => model.value)
</div>
<div id="submitbutton">
@Html.EJS().Button("btn").Content("Post").Render()
</div>
</div>
</div>
} |
Output:
|
|
Kindly check with the above sample. If issue still exists in your end, please revert us with simple issue replicating sample, which helps us to check and provide you the solution at earliest.
Regards,
Ponmani M
PE
Petr
May 17, 2021 09:59 PM UTC
Hi Ponmani,
and thank you for your feedback.
My bad - I forgot to change the currency from EUR, so the problem wasn't obvious.
It indeed works for USD and EUR by default, but that's about it - try your example with e.g. Swiss Frank (CHF) or Japanese Yen (JPY) - it will always return $.
Loading cldr/main/currencies.json seems to solve this though.
Unless I add something outside the file (e.g. Cryptocoin) - then the fallback would again be USD.
Thanks again,
Petr
PM
Ponmani Murugaiyan
Syncfusion Team
May 18, 2021 08:11 AM UTC
Hi Petr,
Sorry for the inconvenience caused.
Yes, the currency symbol for given currency will be obtained from the CLDR data. Therefore, we need to load the CLDR data for that culture, as well as set the culture of the corresponding currency in the component's locale property.
Globalization: https://ej2.syncfusion.com/aspnetmvc/documentation/numerictextbox/globalization/#localization
Regards,
Ponmani M
PE
Petr
May 18, 2021 11:33 AM UTC
Hi Ponmani,
yes, that's what I've mentioned in my previous answer.
Thanks for helping,
Petr
PM
Ponmani Murugaiyan
Syncfusion Team
May 19, 2021 04:45 AM UTC
Hi Petr,
Most Welcome.
Regards,
Ponmani M
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
PE Petr
- Mar 31, 2021 07:12 PM UTC
- May 19, 2021 04:45 AM UTC