How to submit a form with a link in ASP.Net MVC?

I have an HTML form and I have a Controller action that accepts a POST request. Everything works with a regular submit button, but instead I would like to send a form with a link (<a> -tag) to be able to further control the formatting. Is there a way to make this nicely built into the ASP.NET MVC Framework, or should I write my own extension method? Is it possible to do this without javascript (I will use AJAX in the future, but it should work without it).

+4
source share
4 answers

Here is a complete example. Please note that this specific example does something quite important: it has a reserve for browsers with JavaScript disabled.

+3
source

If javascript and jQuery are enabled, this effectively replaces all link buttons with links:

$("input:submit").hide().each(function (index, Element) { var elm = $(Element); elm.after($("<a href=#>" + elm.val() + "</a>") .click(function () { elm.click(); }) ); }); 

Based on the message associated with the accepted answer.

+1
source

I do not know the helper, and as far as I know, it is not possible to submit the form using the anchor tag without using javascript.

0
source

You cannot "submit a form" using the link (<a>) without Javascript. Javascript will generate a standard POST request (just like clicking a submit button) behind the scenes.

There are other ways to work around solutions with JS disabled; see what @Craig Stuntz sent.

0
source

All Articles