使用 Url.action() 传递动态 javascript 值

编程入门 行业动态 更新时间:2024-10-25 12:18:38
本文介绍了使用 Url.action() 传递动态 javascript 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

谁能告诉我如何使用 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() 方法是服务器端的过程,所以你不能将 client-side 值作为参数传递给该函数.您可以将 client-side 变量与此方法生成的 server-side 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, which is a string on the output. Try something like this:

var firstname = "abc"; var username = "abcd"; location.href = '@Url.Action("Display", "Customer")?uname=' + firstname + '&name=' + username;

@Url.Action("Display", "Customer") 在 server-side 上处理,字符串的其余部分在 上处理>client-side,将 server-side 方法的结果与 client-side 连接起来.

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 值

本文发布于:2023-11-03 20:39:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556036.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动态   Url   action   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!