How to Pass textbox value using @html.actionlink in asp.net mvc 3

后端 未结 4 2044
盖世英雄少女心
盖世英雄少女心 2020-12-11 01:55

How to Pass value from text using @html.actionlink in asp.net mvc3 ?

4条回答
  •  执念已碎
    2020-12-11 02:34

    Rather than passing your value using @Html.actionlink, try jquery to pass your textbox value to the controller as:

    $(function () {
        $('form').submit(function () {
            $.ajax({
                url: this.action,
                type: this.method,
                data: { search: $('#textboxid').val()},
                success: function (result) {
                    $('#mydiv').html(result);
                }
            });
            return false;
        });
    });
    

    This code will post your textbox value to the controller and returns the output result which will be loaded in the div "mydiv".

提交回复
热议问题