Question

I am trying to list many Categories in Ajax.ActionLink. I want to give name of controller and ActionLink name dynamically. Is there a way of doing this ?

Here is the code I want to insert parameters.

            @if (ViewBag.MainList != null)
            {
                foreach (var item in ViewBag.MainList)
                {
                <option data-is-secure-trade="0" value="3530">
                    @Ajax.ActionLink(item.Param1,
                     item.Param2, new AjaxOptions { 
                     HttpMethod = "Post" })
                </option>
                }
            }

No correct solution

OTHER TIPS

You need to use this overload of Ajax.ActionLink where you can specify the route values:

@Ajax.ActionLink("Link text",
                 "ActionName",
                 new { controller = "MyController" },
                 new AjaxOptions { HttpMethod = "Post" })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top