问题
I have problem passing hidden field value in actionlink parameter:
productView:
@Html.ActionLink("ProductCompare",
"ProductCompare",
new { ProductIds= **hdnSelectedProductId**)
@Html.Hidden("hdnSelectedProductId")
Controller Action:
public ActionResult ProductCompare(string ProductIds)
{
return View();
}
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/10464003/how-to-use-pass-hidden-field-value-in-actionlink