本文介绍了ASP.NET中的转义功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在经典的asp中,我可以使用escape内置函数(服务器端 函数),如下所示: < script language = javascript> ; var myContent = unescape(<%= escape(strContent)%>) < / script> 我如何在asp.net中执行此操作?好像逃生服务器端功能没有 更长时间在asp.net中提供,或者我在这里遗漏了什么? 提前致谢, - Danny Ps。不要建议我运行Javascript转义函数,因为我需要在服务器端转义这个。 解决方案 实际上,这不是ASP功能,仅限于VBScript 语言。 System.Text命名空间提供了许多函数,用于将字符串转换为ASCII和Unicode。 希望这会有所帮助, Mark Fitzpatrick Microsoft MVP - FrontPage " Danny" <哒****** @ NoSPAMmyrealbox.com>在消息中写道 新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ... 在经典的asp,我可以使用这样的escape内置函数(服务器端函数): < script language = javascript> var myContent = unescape(<% = escape(strContent)%>)< / script> 如何在asp.net中执行此操作?似乎逃生服务器端功能在asp.net中没有提供更长时间,或者我在这里遗漏了什么? 提前致谢, - Danny Ps。不要建议我运行Javascript转义功能,因为我需要在服务器端转义它。 - Peter O''Reilly " Peter O''Reilly" < Pe的*********** @ timeinc.com N 2 O 2 .S P AM>!!;!在消息中写道 新闻:OM ************** @ TK2MSFTNGP09.phx.gbl ... - Peter O''Reilly 谢谢Peter,但Server.HTMLEncode / Decode无法帮助我。 我想要的实际发送数据是逃避格式为Javascript 函数,Javascript将unescape就像我在第一篇文章中解释的那样: < script language = javascript> var myContent = unescape (小于%=逃逸(strContent)%>) 将/脚本> sContent可以包含换行符,apostrophy,报价等。即这就是为什么我想在我将它发送到Javascript之前更改数据以避免脚本错误 Javascript尝试加载它。 有什么想法吗? In the classic asp, I can use escape built-in function (server sidefunction) like this: <script language=javascript>var myContent = unescape(<%=escape(strContent)%>)</script> How do I do that in asp.net? Seems like escape server side function is nolonger provided in asp.net, or am I missing something here? Thanks in advance, - Danny Ps. Don''t suggest me to run Javascript escape function, since I need toescape this on the server side. 解决方案 Actually, this wasn''t an ASP feature and was limited to the VBScriptlanguage. The System.Text namespace offers a number of functions fortransforming strings into ASCII and Unicode. Hope this helps,Mark FitzpatrickMicrosoft MVP - FrontPage "Danny" <da******@NoSPAMmyrealbox.com> wrote in messagenews:%2****************@TK2MSFTNGP11.phx.gbl... In the classic asp, I can use escape built-in function (server side function) like this: <script language=javascript> var myContent = unescape(<%=escape(strContent)%>) </script> How do I do that in asp.net? Seems like escape server side function is no longer provided in asp.net, or am I missing something here? Thanks in advance, - Danny Ps. Don''t suggest me to run Javascript escape function, since I need to escape this on the server side.--Peter O''Reilly"Peter O''Reilly" <Pe***********@timeinc.com!N!O!.S!P!AM!> wrote in messagenews:OM**************@TK2MSFTNGP09.phx.gbl... -- Peter O''Reilly Thanks Peter, but Server.HTMLEncode/Decode can''t help me.What I want actually send the data in "escape" format to Javascriptfunction, and Javascript will "unescape" it.Like what I explained in my first post: <script language=javascript>var myContent = unescape(<%=escape(strContent)%>)</script> sContent can contain linebreak, apostrophy, quote, etc. That''s why I want tochange the data before I send it to Javascript to avoid script error whenJavascript tries to load it. Any ideas? 这篇关于ASP.NET中的转义功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 22:54