routevalues

Adding dynamic parameters with Html.BeginForm and jQuery submit

自作多情 提交于 2019-11-30 16:25:14
// html <% using (Html.BeginForm("MyAction", "MyController", new { id = ViewContext.RouteData.Values["id"] }, FormMethod.Post, new { enctype = "multipart/form-data", class="myForm" })) { %> <input type="file" name="blah" /> <% } %> // script $container.find('.myButton').click(function() { $container.find('.myForm').submit(); }); Before the form is submitted, I need to add some extra parameters (route values) which can only be calculated at the time of submit. How do I do that? You could append a hidden field to the form before submitting it: $container.find('.myButton').click(function() { var

MVC ActionLink add all (optional) parameters from current url

☆樱花仙子☆ 提交于 2019-11-27 11:43:03
The very famous ActionLink : <%: Html.ActionLink("Back to List", "Index")%> Now, this link is in my Details view. The Index view is a search page. The URL of that looks like this: http://localhost:50152/2011-2012/Instelling/Details/76?gemeente=Dendermonde&postcode=92**&gebruikerscode=VVKSO114421&dossiernr=114421%20&organisatie=CLB As you can see, quite the amount of parameters. Obviously I want to keep all these parameters when I return to the Index page, so I need to add them in the ActionLink . Now, I'm tired of doing that manually, it's ok for 1, but not for 6. This should go a lot easier.