How to pass data to the controller while calling transfer page API in ejm?
Pass data to controller by calling transfer page API
You can pass the desired value to the controller by means of the “data” attribute available in the transferPage API.
You can refer the following code examples where a string value is passed with the “text” attribute. This value gets passed on to the controller once the action calls for that particular page.
Script
<script> //Click action of some element function select(e) { App.transferPage(App.activePage, "Home/" + e.text.toLowerCase(), { data: { text: e.text} }); } </script> |
While the action gets called, you have to get the string value with the same name that you defined it with, in the transferPage API. Here, in client-side, it is sent with the “text” attribute. Refer to the following code examples where the value catches with the string type variable “text”.
C#
//Helper public ActionResult Item1(string text) { ViewBag.text = text; return View(); }