3

Is it possible to call a C# function in my codebehind from javascript?

2
  • You might just use WebServices and AJAX calls... Commented Oct 26, 2010 at 7:22
  • possible duplicate of Can you call C# function from javascript? Commented Oct 26, 2010 at 7:23

2 Answers 2

4

Yes, you could use PageMethods.

Sign up to request clarification or add additional context in comments.

2 Comments

Another link to the PageMethods... sappidireddy.wordpress.com/2008/03/31/…
Thanks @Darin. This looks like the way too go. I have one issue though, i'm getting a javascript error stating that PageMethods is not recognised. Could you think of something I am doing wrong?
1

You cannot call server-side code ‘directly’ from client-side code. That is because by design, the server side code executes at server side and client side code at the client. However there are some workarounds. To call serverside code from javascript, you will need to use AJAX, and the easiest way out, is to use the ASP.NET AJAX Extensions.

Check this link

How to call Server Side function from Client Side Code using PageMethods in ASP.NET AJAX

1 Comment

This is a copy of my answere here ;-) stackoverflow.com/questions/3994150/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.