In my ASP.NET MVC application I want a user to add a value into a textbox and then press my Ajax.ActionLink. I want to do something like this:
Ajax.ActionLink("Go", "Action", "Controller", new { value = textbox1.value })
Or how else can I get this textbox value back to my action? Jquery?
You may run action using AJAX $.get method:
<script type="text/javascript">
$(document).ready(function()
{
$("#t").change(function()
{
RunAction();
});
RunAction();
});
function RunAction()
{
var action = '<%= Url.Action("Action", "Controller") %>';
var data = $("#t").serialize();
$.get(action, data);
}
</script>
<input type="text" id="t" />
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