Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

Please let me know how can i call a method in the code behind from the java script.
Posted

 
Share this answer
 
Check answers from Google[^].
 
Share this answer
 
You cannot. JavaScript works on the client side, so there are no "calls" to it. Using Google, you will find many solutions of the problem, but you should understand that they don't "call" any script functions, the actually help to create them and make sure they are called. One convenient method of doing when the page is loaded so is using ScriptManager.RegisterStartupScript:
Call to javascript Function from code behind using ScriptManager.RegisterStartupScript[^].

You can create scripts handling various events. No matter what you do, the whole page is generated on the server side and fully loaded on the client side and called in the browser. Before next HTTP request (including postbacks), client and server sides do not even communicate.

—SA
 
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