If I am using an Ajax.ActionLink helper, and I need to pass a couple parameters to the controller action, how can I get the value of a TextArea that is not bound to a model?
For instance, I want the user to fill out a textarea, and then click Save, sending the textarea value to the controller action for further processing.
Do I use ViewBag? If so, how do I assign the value of a DOM element to ViewBag?
ViewBag is a server-side concept. It does not exist once the page has been rendered.
There is no way that I know of to declaratively link a field on the page with an action parameter.
To do what you want you have two options:
– get rid of the Ajax.ActionLink helper, and write some Javascript (sorry, Ican’t really help you there)
– Use to Ajax.BeginForm instead and put the relevant fields in the form, so that a click on the submit button will submit the form back to your action through ajax.