目前,我正在MVC应用程序上工作,因为我需要将页面呈现给MVC应用程序中的另一个动作,因为我需要将Id参数传递给该动作。
这是我的代码。
var CardCode=$('#CardCode').val();
if (str.substr("successfully")) {
window.location.href='@Url.Action("EditPartner","MstPartner",new { id = CardCode})';
}
在代码中,当我将值传递给该ID时,即id=CardCode
在那里不允许,那么如何将CardCode值传递给该动作?请给一些建议。
您的代码无效,因为您无法在其中传递变量。仅在值是硬编码的情况下才有效
window.location.href='@Url.Action("EditPartner","MstPartner",new { id = "123"})';
你能做的就是使用一种Replace
方法
var CardCode=$('#CardCode').val();
if (str.substr("successfully")) {
window.location.href='@Url.Action("EditPartner","MstPartner",new { id = "CC"})'.replace("CC",CardCode);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句