Passing html textbox value as a parameter to controllers method in asp.net MVC

前端 未结 3 1763
再見小時候
再見小時候 2021-01-26 12:12

I want to pass the Html.Textbox value to a controller from anchor tag, so that I can search the value passed to a controller. Please tell me how can I achieve this.

3条回答
  •  独厮守ぢ
    2021-01-26 13:02

    use jquery

    @Html.TextBox("String", null, new { @class="txtString" })
    @p
    

    then in your script

    $('.txtString').on('blur', function(){
        $('.linkAction').attr('src', '@Url.Action("Index", "Home", new { text = "----" })'.replace("----", $('.txtString').val()));
    });
    

提交回复
热议问题