I want to pass an input control value (say textbox1.value or a javascript variable) to a controller action method (as a parameter) without a form post (using Ajax.ActionLink). Please see the code below.
Is it possible to assign something like new {name = textbox1.value} in Ajax.ActionLink.
View
<input type="text" id="textbox1" />
<%= Ajax.ActionLink("mylink", "linkfunction", new {name = textbox1.value}, new AjaxOptions { UpdateTargetId = "result"}) %>
<span id="result"></span>
and controller action is:
public string linkfunction(string name)
{
return DateTime.Now.ToString();
}
This is similar to this:
ASP.NET MVC : AJAX ActionLink- Target an HTML attribute
Plus, you don't need to pass in the control name into your Action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With