Seperate js File utf-8 not working in ASP.NET MVC Razor

扶醉桌前 提交于 2021-01-27 14:52:05

问题


I have a textBox. When I click mybtn if myTxtBox is empty a tooltip appears and give the message which attached to 'data-original-title'. It's working fine but when I add turkish charachters inside text instead of "Some text", these charachters are shown as a question mark.

$("#mybtn").on('click', function (e) {
if ($("#myTxtBox").val() == "") {
                MyTooltipCreator("#myTxtBox");
                $("#myTxtBox")
                    .attr('data-original-title', "Some text")
                    .tooltip('fixTitle')
                    .tooltip('show');
            }
 });

The strange thing is when I add my scripts inside my cshtml file it works very well. The problem occurs after I move my scripts into a seperate js file.


回答1:


If it is a static text then I think you need to change your js file Encoding Type.

Open your js file in Visual Studio. Click to "File" from top left corner. Then click to "Save as" your file. There is an arrow next to the "Save" button. Click to this arrow and select "Save with Encoding" and confirm the Save as process. In "Advanced Save Options" popup select Unicode(UTF-8) Encoding and click "OK".



来源:https://stackoverflow.com/questions/42158277/seperate-js-file-utf-8-not-working-in-asp-net-mvc-razor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!