views:

27

answers:

2

I have a link (well a few different links actually) that target FileContentPath actions that return pdf/excel files etc that are generated in the controller. problem is that I want these actions to receive the formcollection as well that may be changing all the time depending on the users interaction with the page. Is there a workaround way to get the formcollection to these action methods

i.e. I have links as below

<a href="/Home/GetPdf/42" id="btn_pdf_1">Get PDF</a>

and want to be able to pass some hidden fields to this through?

+1  A: 

You can change the path of the href to what ever you want. So you can get the values from form and add whatever needs adding to you paths. This does not need a form submitted you just need to set up a function for when the link or when the form is filled.

matpol
+1  A: 

When you make a GET request the data is sent in the url. So if you want to send that data you need to do that in the url (as query strings).

Mattias Jakobsson
Thanks for the reply, I was hoping to pass quite a lot of table html through a hidden field to parse on the backend (I'm using jquery tablesorter etc and wanted to send this sorting to the backend) which is why I was hoping for a neater solution but I don't think there's a way around it. cheers
Israfel
You can use a form with action="get". Then the data from the hidden fields within that form will be sent as well.
Mattias Jakobsson
Thanks Mattias, I'm actually skipping the hidden field now and manipulating the data and adding it to the querystring using jquery now and it's worked well
Israfel