如何使用/ ActionLink的中传递隐藏字段值 [英] How to use/pass hidden field value in ActionLink

查看:138
本文介绍了如何使用/ ActionLink的中传递隐藏字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ActionLink的参数传递的隐藏字段的值问题:

I have problem passing hidden field value in actionlink parameter:

@Html.ActionLink("ProductCompare", 
                 "ProductCompare", 
                 new { ProductIds= **hdnSelectedProductId**)
@Html.Hidden("hdnSelectedProductId")

控制器动作:

public ActionResult ProductCompare(string ProductIds)
{
    return View();
}

当用户选择任何产品我一直使用JavaScript把产品ID在hdnSelectedProductId。
现在,当上ProductCompare链路用户点击我想通过这个隐藏字段的值到控制器。
请指引我。

When user select any product i keep putting product ids in hdnSelectedProductId using javascript. Now when user click on ProductCompare link i want to pass this hidden field value to controller. Please guide me.

推荐答案

一个解决方案是使用jQuery附加click事件这将读取隐藏字段并将其追加到链接的href属性。

One solution is to use jQuery to attach a click event which would read the hidden field and append it to the link's href attribute.

另一个解决方案是保存的价值,如果你知道它是什么,在ViewData的,用它来代替隐藏字段的值。

The other solution is to store the value, if you know what it would be, in ViewData and use it instead of hidden field value.

这篇关于如何使用/ ActionLink的中传递隐藏字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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