我如何传递一个文本框的值我Ajax.ActionLink? [英] How can I pass a Textboxes value to my Ajax.ActionLink?

查看:429
本文介绍了我如何传递一个文本框的值我Ajax.ActionLink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET MVC应用程序,我希望用户添加一个值到一个文本框,然后preSS我Ajax.ActionLink。我想要做这样的事情:

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(走,行动,控制器,新{值= textbox1.value})

Ajax.ActionLink("Go", "Action", "Controller", new { value = textbox1.value })

还是怎么回事,我可以得到这个文本框的值回我的行动? jQuery的?

Or how else can I get this textbox value back to my action? Jquery?

推荐答案

您可以使用运行操作AJAX $不用彷徨方式:

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" />

这篇关于我如何传递一个文本框的值我Ajax.ActionLink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆