简体   繁体   中英

Setting javascript variable from model strings containing Swedish Characters

Newbie type question

I have the following function to set a grids title and fields (dynamic grid)

网格标题功能

The Model variables can contain Swedish characters

在此处输入图片说明

But when this is all passed to the client , the swedish characters look like this.

在此处输入图片说明

The Grid handles this fine, until it goes to export the Grid to Excel. The columns are fine , but the titles are how the rendered function looks. 在此处输入图片说明

My assumption that this is caused because of the conversion happening when setting from the model variable.

Appreciate any ideas people have :)

Razor is a HTML-rendering engine, and is HTML-escaping each @... substitution. If you know your content is HTML-safe, you can mark it so:

field: "@Html.Raw(d.field)"

(and analogously for any other place where you are injecting content in JS strings and not in HTML).

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