Submitting the form by button, programmer have to assign only the type of that button and on click this button all the data can be get on the server side. On drop-down change we have manually submit the form by either specifying "OnSelectionChanged" event or some jquery functions.
In earlier article I have created DropDownList in MVC, to submit the form we can simply use only submit function on change event of the list.
@Html.DropDownList("ddlname", "List to bind", "--default title--", new { onchange = "submit();" })
After writing this code on change it will post all the data on the form to server-side but programmer have to use same name in action method as used here “ddlname”. When we use view-model to bind the data then dropdown list’s code will be changed as:
@Html.DropDownListFor(model => model.Property , "List to bind", "--default title--", new { onchange = "submit();" })
This code will contains the value of the property of model as used here. The value will submit on change the selection of this drop-down list. Programmer can change other controls value by using this code.
Suppose we have to select country, state and city on the form in hierarchy manner. On change the country, states drop-down list should change and on change of state, city drop-down list should change. By implement this functionality we can use this submit functionality.
In earlier article I have created DropDownList in MVC, to submit the form we can simply use only submit function on change event of the list.
@Html.DropDownList("ddlname", "List to bind", "--default title--", new { onchange = "submit();" })
After writing this code on change it will post all the data on the form to server-side but programmer have to use same name in action method as used here “ddlname”. When we use view-model to bind the data then dropdown list’s code will be changed as:
@Html.DropDownListFor(model => model.Property , "List to bind", "--default title--", new { onchange = "submit();" })
This code will contains the value of the property of model as used here. The value will submit on change the selection of this drop-down list. Programmer can change other controls value by using this code.
Suppose we have to select country, state and city on the form in hierarchy manner. On change the country, states drop-down list should change and on change of state, city drop-down list should change. By implement this functionality we can use this submit functionality.