单独的 js 文件 utf-8 在 ASP.NET MVC Razor 中不起作用 [英] Seperate js File utf-8 not working in ASP.NET MVC Razor

查看:48
本文介绍了单独的 js 文件 utf-8 在 ASP.NET MVC Razor 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框.如果 myTxtBox 为空,我单击 mybtn 时会出现一个工具提示并给出附加到数据原始标题"的消息.它工作正常,但是当我在文本中添加土耳其语字符而不是某些文本"时,这些字符显示为问号.

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');
            }
 });

奇怪的是,当我将脚本添加到我的 cshtml 文件中时,它运行良好.在我将我的脚本移动到一个单独的 js 文件后,问题发生了.

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.

推荐答案

如果是静态文本那么我认为你需要更改你的 js 文件的编码类型.

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

在 Visual Studio 中打开您的 js 文件.点击左上角的文件"角落.然后单击另存为"您的文件.旁边有一个箭头保存"按钮.单击此箭头并选择使用编码保存"并确认另存为过程.在高级保存选项"弹出窗口中选择 Unicode(UTF-8) 编码并点击确定".

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".

这篇关于单独的 js 文件 utf-8 在 ASP.NET MVC Razor 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆