I’ve got a common layout page for views. This layout page contains a dropdown list, which shows the list of available dates. What I want is to reload this page having changed the data param only. The controller, action and any other params should be somehow taken from the current request context.
If I wanted to do it manually on every view, I’d say it would be equal to
@Html.ActionLink(
"",
"I need to have current action name here",
new { date = "The Value of the chosen SelectListItem" });
How can I achieve this? Or is there any different approach?
Information about current action is available in
RequestContext, you could access it directly:In your case I would add the url to option data attribute and then work with it with jQuery:
How to fetch data attribute on dropdownlist change can be seen in this FIDDLE.