Click here to Skip to main content
15,905,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a javascript function in sample1.cshtml page
C#
function abc()
{

}

I need to call this function in some other Smple2.chhtml page
Posted
Updated 4-Dec-13 1:15am
v3
Comments
Pheonyx 4-Dec-13 4:16am    
I might be wrong, but I'm not convinced you can.

Javascript is client side code where as CS is server side, at least that is my understanding. Especially in the MVC approach to web.

Why do you want to try and call Javascript from C# ?
santhosh-padamatinti 4-Dec-13 6:03am    
If you are really looking for sharing the java script function in two different CSHTML pages, keep that js function in Layout page. It will be available in two pages.

1 solution

You don't. The server cannot execute code on the client machine.
 
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