Here Mudassar Ahmed Khan has explained with an example, how to Call JavaScript Function from Controller in ASP.Net MVC Razor.
There is no direct way to call JavaScript function from Controller as Controller is on Server side while View is on Client side and once the View is rendered in Browser, there is no communication between them.
Hence the only possible way is to use the ViewBag object and pass the script to call a particular JavaScript function from Controller to View.
↧