Issa Saman
Issa Saman

Reputation: 110

pass a symbol or special characters from model to view in asp.net core

my problem is strange property EmployeePhone in the model has value "+96279000000"

so I pass it for javascript

$("#EmployeePhone").intlTelInput("setNumber", "@Model.EmployeePhone");

but the problem is at rendering time the value appears as

$("#EmployeePhone").intlTelInput("setNumber", "+96279000000");

the expected result should be

$("#EmployeePhone").intlTelInput("setNumber", "+96279000000");

how to solve this?

Upvotes: 1

Views: 734

Answers (1)

Pedro Perez
Pedro Perez

Reputation: 932

You can try with @Html.Raw(@Model.EmployeePhone);.

Or:

function initialize() {
    var employeePhone= @Html.Raw(Json.Encode(Model.EmployeePhone));
}
...
$("#EmployeePhone").intlTelInput("setNumber", employeePhone);

Upvotes: 2

Related Questions