Popup to action with parameters

May 12, 2011 at 10:44 AM
Edited May 12, 2011 at 10:45 AM

Hi!

I have a situation where I want to call a popup to show Product details by calling an action that accepts several parameters. I want to do this for each product in foreach loop.

foreach (var product in Model.Products) {
@(Html.MakePopup<DetailsController>(o => o.Details(product.Index, true), modal: true, prefix: "d1" + i, width: 900, height: 700)) ;
@(Html.PopupActionLink<DetailsController>(a => a.Details(product.Index, true), prefix: "d1" + i))
} 

Can I move the MakePopup method outside the foreach loop so that only once is the <script> generated and if yes how can I do it, since the action method acceps parameters within the call?

Tnx in advance!

Coordinator
May 12, 2011 at 10:48 AM

you can and you MUST move it out of the foreach

the parameters that the MakePopup asks are not needed actually it just that helper is lambda and strongly typed so just give it nulls zeroes whatever

May 12, 2011 at 2:12 PM

Great, tnx!