Possible Duplicate:
Call ASP.NET Function From Javascript?
this question is asked by interviewer. can anybody tell me that is it possible? if yes then how.
Possible Duplicate:
Call ASP.NET Function From Javascript?
this question is asked by interviewer. can anybody tell me that is it possible? if yes then how.
You can, but not directly. You'd have to use an AJAX implementation or write an AJAX call yourself using the XmlHttpRequest.
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
Or you can call a managed C# (or whatever) language function in a Silverlight control by calling through the javascript bridge.
This is one of those tricky questions where the answer is "not directly, but with a little help from Ajax or the web page DOM i can, and this is how i do it....".
You can call C# functions through Javascript, but not directly. That is to say, you just can't include the namespace and make a direct call to the function. The request has to go indirectly through an interface at the web server which handles browser requests and then sends them to the functions. There are several ways of doing this
Try This
http://stackoverflow.com/questions/2522967/call-a-c-method-from-javascript
http://globetech.wordpress.com/2008/01/07/call-managed-c-method-from-javascript-code/
http://www.msnewsgroups.net/csharp/t156-how-call-function-javascript.aspx
This all url has diffren examples follow This will suerly help you