通过传递动态Url.action JavaScript的值() [英] Passing dynamic javascript values using Url.action()
问题描述
谁能告诉如何通过使用Url.action()动态值。
Could anyone please tell how to pass dynamic values using Url.action().
类似,
var firstname="abc";
var username = "abcd";
location.href = '@Html.Raw(@Url.Action("Display", "Customer", new { uname = firstname ,name = username}))';
姓名,用户名是没有得到下文称的Url.action()方法中。
firstname, username is not getting reffered inside the Url.action() method.
如何通过使用Url.action()?这些动态值
How to pass these dynamic values using Url.action()?
推荐答案
的 @ Url.Action()
方法是在服务器端proccess,所以你不能传递客户端值这个函数作为参数。可以Concat的与由本方法生成的服务器端的URL的客户端的变量。尝试是这样的:
The @Url.Action()
method is proccess on the server side, so you cannot pass a client side value to this function as a parameter. You can concat the client side variables with the server side url generated by this method. Try something like this:
var firstname = "abc";
var username = "abcd";
location.href = '@Url.Action("Display", "Customer")?uname=' + firstname + '&name=' + username;
的 @ Url.Action(显示,客户)
在服务器端进行处理,该字符串的其余部分是在客户端处理,串联的服务器端方法的客户端的结果。
The @Url.Action("Display", "Customer")
is processed on the server-side and the rest of the string is processed on the client-side, concatenating the result of the server-side method with the client-side.
这篇关于通过传递动态Url.action JavaScript的值()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!