Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Pass Dropdown selected value to Controller on Selected index change

Tags:

asp.net-mvc

i am new to MVC and i am stuck at one point into project i wanted to check the Availability of a Batch,i am using a Dropdownlist and it is populate by Batch table.

My Question is when i am selecting a batch from drop downlist on same time it will give Msg that Batch is available or Not.

Batch Table Structure is: BatchID BachName TotalSeat AvailableSeat 01 L1 50 40 02 L2 20 20

i don't know how to do this task.

like image 664
Harshal Avatar asked Nov 30 '25 15:11

Harshal


1 Answers

You can see the different solutions form this link:

@using (Html.BeginForm("Method", "YourController")) {

@Html.DropDownList("Id", ViewBag.DropDownCollection as SelectList, "--pick--", new {
    title = "Pick Batch",
    onchange = "submit();"
});

}

ActionResult

public ActionResult Method(string Id)
{
 //do the logic here
}
like image 76
Altaf Sami Avatar answered Dec 03 '25 04:12

Altaf Sami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!