admin管理员组文章数量:1398806
I recently installed Visual-Web-Developer 10 and open my old asp 3.5 solution in it
and converted it to asp 4 solution.
every thing is working fine exept one strange problem:
suddenly all chars like: ' or " in header script code bee: ' or "
and this making all my javascript do not work and give error in all my solutuin pages.
i tryed to save the page in different encoding but it did not help: here is example of what happening: in server side code:
HtmlGenericControl Include = new HtmlGenericControl("script");
Include.Attributes.Add("type", "text/JavaScript");
Include.InnerText = "browser = \"ie\"; browserVer = '8'; bodyDir = 'rtl'; adverID = '123'; webKind = 'adver';";
Page.Header.Controls.Add(Include);
Include.Dispose();
on user side i get:
<script type="text/JavaScript">browser = "ie"; browserVer = '8'; bodyDir = 'rtl'; adverID = '123'; webKind = 'adver';</script>
big thanks for any halp chainan
I recently installed Visual-Web-Developer 10 and open my old asp 3.5 solution in it
and converted it to asp 4 solution.
every thing is working fine exept one strange problem:
suddenly all chars like: ' or " in header script code bee: ' or "
and this making all my javascript do not work and give error in all my solutuin pages.
i tryed to save the page in different encoding but it did not help: here is example of what happening: in server side code:
HtmlGenericControl Include = new HtmlGenericControl("script");
Include.Attributes.Add("type", "text/JavaScript");
Include.InnerText = "browser = \"ie\"; browserVer = '8'; bodyDir = 'rtl'; adverID = '123'; webKind = 'adver';";
Page.Header.Controls.Add(Include);
Include.Dispose();
on user side i get:
<script type="text/JavaScript">browser = "ie"; browserVer = '8'; bodyDir = 'rtl'; adverID = '123'; webKind = 'adver';</script>
big thanks for any halp chainan
Share Improve this question edited Oct 28, 2010 at 22:18 Gabriele Petrioli 196k34 gold badges271 silver badges328 bronze badges asked Oct 28, 2010 at 22:05 cheinancheinan 791 gold badge2 silver badges7 bronze badges2 Answers
Reset to default 6Use the InnerHtml
property instead, to add the contents of the script. The InnerText
gets converted..
Quote from InnerText
Unlike the
InnerHtml
property, theInnerText
property automatically encodes special characters to and from HTML entities. ...
Use InnerHtml property instead of InnerText.
*"The InnerHtml property does not automatically encode special characters to and from HTML entities. HTML entities allow you to display special characters, such as the < character, that a browser would ordinarily interpret as having special meaning. The < character would be interpreted as the start of a tag and is not displayed on the page. To display the < character, you would need to use the entity <
.
本文标签: javascriptchars like 39 or quot in header script code become amp39 or ampquotStack Overflow
版权声明:本文标题:javascript - chars like: ' or " in header script code become: &#39; or &quot; - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744647756a2617500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论