Click here to Skip to main content
15,915,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one help me?

How to call javascript function from controller class in MVC app.
Please give some sample code, I am new in MVC.

Thanks
Posted
Updated 30-Apr-18 10:20am
v2
Comments
bbirajdar 23-Nov-11 8:46am    
Find your answer here http://www.codeproject.com/Answers/180285/how-to-call-javascript-function-form-controller-ac.aspx#answer1
[no name] 24-Nov-11 3:13am    
The problem that B Birajdar referred to is more complex than yours.

If you don't need to get a return value back from the javascript function, you can just render the function using JavaScriptResult:

C#
public ActionResult MyAction()
{
    return JavaScript("window.alert('HELLO');");
}
 
Share this answer
 
hi Please see my answer at stackoverflow at following link

asp.net mvc - Call javascript from MVC controller action - Stack Overflow[
 
Share this 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