Click here to Skip to main content
12,297,823 members (53,129 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MVC Application
how to call javascript function from Controllers file in MVC
Posted 6-Apr-11 19:58pm
Edited 6-Apr-11 20:05pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I guess, calling javascript from controllers class is not possible.

Exact same question asked here: http://stackoverflow.com/questions/4284618/how-to-call-javascript-function-from-controllers-file-in-mvc[^]

Have a look at more discussion of above thread here confirming it cannot be done:
http://stackoverflow.com/questions/2709978/call-javascript-from-mvc-controller-action[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

There is one way you can call javascript function from controller. Not directly but going through view.

Just pass the name of your javascript function to view from controller using model and then you can call it from view using document.ready provision of jquery.


HTH
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 14 Apr 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100