开发者

rails escape_javascript in .net

For rails developer please check 开发者_运维问答my last paragraph.

Is there an equivalent of escape_javascript in rails for .net specifically .net mvc2? I am going to return some JavaScript which needs to be escaped since I am getting the code from another view using RenderPartialViewToString http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/

You can see what escape_javascript does here Why escape_javascript before rendering a partial? if your not familiar with its functionality.

Rails developers: It feels like this function should be easy to implement or port for rails so can someone explain what it does more than just escaping qoutes?


If you go here, and click on the show source link, you can see the source to the method. It is just a Regex.Replace() call.


ASP.NET MVC provides 9 ActionResults, one of them is the JavascriptResult.

In your Action method:

return JavaScript("javascript code");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜