ASP.NET MVC的Javascript的ActionResult [英] ASP.NET MVC Javascript ActionResult

查看:117
本文介绍了ASP.NET MVC的Javascript的ActionResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人有任何的JavaScript actionresults的任何例子吗?我有一个很难得到脚本一旦被退回来执行。谢谢

Anyone have any examples of javascript actionresults? I am having a hard time getting the script to execute once it has been returned. Thanks

推荐答案

下面是一个例子,我在<一个发现href=\"http://devlicio.us/blogs/billy_mccafferty/archive/2009/02/07/beware-of-asp-net-mvc-javascriptresult.aspx\">blog帖子,这实际上将其描述为一个反模式,因为控制器必须有深入查看的知识,以功能。

Here's an example I found on a blog post, which actually describes it as an anti-pattern, because the Controller has to have in-depth knowledge of the View in order to function.

public ActionResult DoSomething() {   
    string s = "$('#some-div').html('Updated!');";   
    return JavaScript(s);   
}  

这篇关于ASP.NET MVC的Javascript的ActionResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆