简体   繁体   English

Asp.Net编码配置

[英]Asp.Net encoding configuration

I am using ASP.NET 4 c# 2010. Well my website has some problem with character encoding. 我正在使用ASP.NET 4 c#2010。我的网站在字符编码方面存在一些问题。 It seems that when I generate my output it is htmlencoded. 似乎当我生成输出时,它是htmlencoded。 So a ' is encoded with #number;... this is not always a good thing because when I need to dynamically insert jscript in my controls, every ' or " are encoded and js doesn't work properly... 所以'用#number编码; ...这并不总是一件好事,因为当我需要在控件中动态插入jscript时,每个'或“都会被编码并且js无法正常工作...

How to correctly tell ASP.NET not to encode? 如何正确告诉ASP.NET不编码? or better telling him that he must correctly manage ' " and other chars like these withput rendering them htmlencoded? 还是更好地告诉他,他必须正确管理'“和其他类似字符,并使其呈现htmlencoded?

An example of string being output: this.MyControl.Attributes["onfocus"] = "execJs('param')" 输出字符串的示例: this.MyControl.Attributes["onfocus"] = "execJs('param')"

well it results so: 结果很好:

<textarea id=".." onfocus="execJs(&#39;param&#39;)">...

This is not correct. 这是不正确的。

好的,简单地说,没有什么可担心的,在这里它解释了所有内容: JavaScript引擎识别的HTML编码字符串,怎么可能?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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