Reputation: 864
I have a Html.DropdownList()
which I have binded data with a viewbag. It works properly. Now what I want is when user select and item from it and after click the action link the selected Item value should set as action link id using jquery or, send the selected item value to a specific controller as a parameter directly. How can I do that?
<div class="col-md-4">
<h2 style="color: #2f6207">dfdfDestination</h2>
@Html.DropDownList("Destin",new SelectList(ViewBag.Destination, "regCde", "Destination","--pickone--"))
</div>
<div class="mylink">
@Html.ActionLink("SEARCH NOW", "MscHome", new {@id = "ssd"})
</div>
How can I do that.
Upvotes: 1
Views: 3265
Reputation: 12491
If you using jquery, you can make ajax call:
$('#Destin').on('change', function (){ //on change drop down selected value
$.ajax({
url: '@Url.Action("YourMethod","YourController")',
cache: false,
type: "POST", //Or GET
dataType: "json",
data: $(this).val(), //here you set your dropdown selected value
success: function(data){
$("#results").append(data); //append your data from controller
}
});
});
Upvotes: 4