maztt
maztt

Reputation: 12294

asp.net mvc posting form values using html.actionlink

how can i post the form values using html.actionlink, don't want to use routes dictionary

<%=Html.ActionLink("Download", "MyFiles", "Jobs", null, new { @class = "cvclick" })%>

Upvotes: 0

Views: 3813

Answers (4)

Navish Rampal
Navish Rampal

Reputation: 482

You can post the data using :-

anthing inside Beginform will be posted

<% using (Html.BeginForm("ActionName", "ControllerName"))
{ %>

 texbox code 

   <input type="submit" class="dASButton" value="Submit" />

 <% } %>

Upvotes: 0

jgauffin
jgauffin

Reputation: 101150

To POST values you could use Spark View Engine and a HTML form:

<form action="myfiles" controller="jobs">
  <hidden name="key1" value="value1" />
  <hidden name="key2" value="value2" />
  <submit title="Download" />
</form>

(The code uses some pretty standard bindings that be wired in Spark)

As for links and ActionLink. I would use the ajax helper instead since it can POST stuff. (Ajax.ActionLink)

Edit

So you want to DOWNLOAD a file? Well. The link should point on an action in your controller. The action should return a FileResult with your file. See here: http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.file(v=vs.90).aspx

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038820

To POST values you could use an HTML form:

<% using (Html.BeginForm("MyFiles", "Jobs")) { %>
    <%= Html.Hidden("key1", "value1") %>
    <%= Html.Hidden("key2", "value2") %>
    <input type="submit" value="Download" />
<% } %>

Upvotes: 2

SLaks
SLaks

Reputation: 887453

A link points to an HTTP GET request.
An HTTP GET request is sent to a URL; the URL must be defined using a route.

Upvotes: 3

Related Questions