How to use/pass hidden field value in ActionLink
Asked Answered
R

1

2

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.

Roxi answered 5/5, 2012 at 16:56 Comment(0)
A
0

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.

Aurilia answered 5/5, 2012 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.