<div class="frame">
<div class="control">
<ej-drop-down-list id="bikeList" datasource="ViewBag.datasource" watermark-text="Select a bike" >
<e-drop-down-list-fields id="empid" text="text" value="text" />
</ej-drop-down-list>
</div>
</div>
<br />
<ej-button id="btn" text="Post value" click="onClick" />
<script>
function onClick() {
var ddlobj = $("#bikeList").data("ejDropDownList");
$.ajax({
url: '@Url.Action("PostValue")',
data: { 'SelectedValue': ddlobj.getSelectedValue() },
type: "post",
cache: false,
success: function () {
},
error: function () {
}
});
}
</script> |
[HttpPost]
public void PostValue()
{
var SelectedValue = HttpContext.Request.Form["SelectedValue"].ToString();
} |
Hi thanks for quick response the example I need is in asp.net core2 mvc application I am using a grid one of the fields is a dropdownlist box what I need is to be able to send selected item in listbox using ajax back to controller, in other words when selection is made on grids dropdown list box I want to send selection back to controller, sorry if I was not very clear.
Thanks
Edmund Herbert
<ej-grid id="Grid" datasource=ViewBag.datasource allow-paging="true"
action-complete="complete" >
---
<e-columns>
---
</e-columns>
</ej-grid>
<script type="text/javascript">
function complete(args) {
if (args.requestType == "beginedit" )
$("#"+this._id+"ShipCountry").ejDropDownList({dataSource:data,width:"100%",change:"change"});
}
function change(args){
var value = args.value; // get the selected value from dropdown list change event
$.ajax({
url: '@Url.Action("PostValue")',
data: { 'SelectedValue': value},
type: "post",
cache: false,
success: function () {
},
error: function () {
}
});
}
</script>
|