c# - Call same method both in client-side and server-side -
i have complex calculation in page , want perform in both client-side , server-side. easier maintenance, prefer write 1 function , call in client , server.
so searching method call javascript function in c# code behind or else satisfy demand. thought service based function call in client ajax , in server simple function; however, obvious work in client because should go server , come back.
any idea?
as stated in comment, can think of 3 options have here.
- use ajax call result controller (server-side calculation only).
- use postback, pretty same option above.
- use javascript interpreter jint, execute same piece of javascript on server side.
i think first 2 prefered, third option might solution if don't call or postback. cause client-side code calculate it's own result, while server-side able same. same code, same result, no call client-side server-side.
a populair javascript interpreter .net might jint example, has proven it's stability , performance. might want check out.
Comments
Post a Comment