如过你在asp.net后台生成html代码然后输出到客户端就可能发生错误。
错误的写法:
onmouseover='currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff ' '
this.style.backgroundColor='#6699ff '此处脚本会认为它是非法的字符串不给予通过,就是提示:illegal character
正确写法:
onmouseover='currentcolor=this.style.backgroundColor;this.style.backgroundColor=\"#6699ff\" '
this.style.backgroundColor;this.style.backgroundColor=\"#6699ff\" 此处加上转义符就可以了。
本文讨论了在ASP.NET后台生成HTML代码并输出到客户端时可能遇到的错误,特别是关于JavaScript脚本中非法字符的问题。通过提供正确的语法示例,详细解释了如何在脚本中使用转义符来避免此类错误,确保代码的正常执行。
8万+

被折叠的 条评论
为什么被折叠?



