0

I have a text box in view and 2 action link in the same form. what I want to do this that when I click action links textbox value will get in ActionResult

Html.BeginForm("downloadpage","Finance"){
<div class="col-5">
    <input type="text" class="form-control" name="txttitle" id="txtval" placeholder="E.g. PAK10NOV18" />
    @Html.TextBox("first_name")
</div>


@Html.ActionLink("Download Master File", "get_master_file");
@Html.ActionLink("Download IBFT File", "get_ibft_file");

}

backend

public ActionResult get_master_file(string txttitle)
{
return View();
}

public ActionResult get_ibft_file(string txttitle)
{
return View();
}

1 Answers1

0

Why don't you use jquery and an ajax call?

Have a button that when you click calls a javascript function. In here you can get the value of the input such as this:

var textvalue = $("#txtval").val();

Create a json such as this:

var json = '{txttitle: "' + textvalue  + '"}';

and call your controller such as this:

$.ajax({
    url:'@Url.Action("//Function", "//Controller")',
    type:'POST',
    data: json,
    contentType:'Application/json',
    success:function(result){
        //Do nothing or do whatever you want
    }
});
JamesS
  • 2,167
  • 1
  • 11
  • 29