I am using asp core 2.0 to develop my MVC application. However, I am using the SharedLocalizer in the view. I use the following code to inject it:
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IViewLocalizer Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
@inject IHtmlLocalizer<SharedResources> SharedHtmlLocalizer
This is how I call my SharedLocalizer:
function updateCommission(agentID) {
var msg = '@SharedLocalizer["Confirm Update Commission?"].Value.ToString()';
if (confirm(msg) == false)
return false;
}
But, my result looks like this:
If I use the SharedLocalizer in my html label / input, it displays fine. When I view my page source, the string also is the '$#1231';
How can I display the correct string with my setup?
I am using asp core 2.0 to develop my MVC application. However, I am using the SharedLocalizer in the view. I use the following code to inject it:
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IViewLocalizer Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
@inject IHtmlLocalizer<SharedResources> SharedHtmlLocalizer
This is how I call my SharedLocalizer:
function updateCommission(agentID) {
var msg = '@SharedLocalizer["Confirm Update Commission?"].Value.ToString()';
if (confirm(msg) == false)
return false;
}
But, my result looks like this:
If I use the SharedLocalizer in my html label / input, it displays fine. When I view my page source, the string also is the '$#1231';
How can I display the correct string with my setup?
Share Improve this question edited Jul 24, 2020 at 10:13 andHapp 3,2072 gold badges23 silver badges21 bronze badges asked Oct 10, 2018 at 7:32 ryan1555ryan1555 1651 silver badge10 bronze badges1 Answer
Reset to default 8Returns markup that is not HTML encoded @Html.Raw
refactor
function updateCommission(agentID) {
var msg = '@Html.Raw(SharedLocalizer["Confirm Update mission?"].Value.ToString())';
return confirm(msg);
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745293623a4621011.html
评论列表(0条)