Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
Hi,
Can I call javascript function from MVC controller action (not from view page) and get return value? How?

Thank You
Posted

1 solution

Hey!

Your MVC controller is typically server side, where javascript runs client side. If you want to pass a value from one to another you have to post the value (for example using a querystring). You cannot access a javascript function while running a MVC Controller method.

You may want to use for example a form with a hidden field and submit the form, the value of the hidden field will be passed to the server where is will be accessible.

Good luck!

Eduard
 
Share this answer
 
Comments
kansalvai 9-Apr-13 3:20am    
this is not the solution okey?
Eduard Keilholz 9-Apr-13 3:53am    
Ofcourse this is not the solution, because in my answer I explain that it's not possible. How can you reply with such an answer?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900