使用JavaScript变量MVC3剃刀视图引擎 [英] using javascript variable in MVC3 Razor view engine
本文介绍了使用JavaScript变量MVC3剃刀视图引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能吗?
@Html.ActionLink( "Link text", "Action Name", new { id = *JAVASCRIPT VARIABLE* })
请与例如code解释。
Please explain with example code.
推荐答案
没有是不可能的,因为.NET MVC 3是服务器端的code和被发送到客户端之前进行评估,而JavaScript是客户端它只能运行code,一旦它在客户端
No it is not possible, because .NET MVC 3 is server side code and is evaluated before being sent to the client, and javascript is Client side code which runs only once it is ON the client
但反过来是可能的:
var jsVar = "@yourMvcVar";
这篇关于使用JavaScript变量MVC3剃刀视图引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文