@Html.EJS().MultiSelect("default").DataSource((IEnumerable<object>)ViewBag.data).Render()
@Html.EJS().Button("Btn").Content("Send").Render()
<script>
document.getElementById('Btn').onclick = function () {
var obj = document.getElementById('default').ej2_instances[0], value = JSON.stringify({ text: obj.text });
const Http = new XMLHttpRequest();
const url = '@Url.Action("About")';
Http.open("POST", url);
Http.setRequestHeader('Content-Type', 'application/json');
Http.send(value);
};
</script> |
public ActionResult Index()
{
ViewBag.data = new string[] { "Badminton", "Basketball", "Cricket", "Football", "Golf", "Gymnastics", "Hockey", "Tennis" };
return View();
}
[HttpPost]
public ActionResult About(string text)
{
//Get the value in text
return View();
} |