简体   繁体   中英

How to pass the string in original format to javascript function

I have a Javascript function below, which takes a label defined in resx.file... Label is something like: Success from customer's price list.

enter code here: $(function () {
    systemadminhourlyrateindex().init(
        '@Html.Raw(Label.SuccessDeleteIsDelegated)' //At this point label is as origin.
    );
});

But when I try to use it in JS function, it dose not escape the single quote from customer's correctly. Instead it adds wierd chars something into the word customers. So it becomes something like customer---s where --- is & # 3 9; Maybe this is ascii for single quote?

This worked out for me.

@Html.Raw(HttpUtility.JavaScriptStringEncode(YouLabel)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM