How to call a C# Method from Javascript
-
Hi all, How to call a C# method from a javascript. for example i am fetching a document.activeElement.value and i want to send this value to the C# method. Is it possible, if some one knows this pls help me thanks in adavance...
-
Hi all, How to call a C# method from a javascript. for example i am fetching a document.activeElement.value and i want to send this value to the C# method. Is it possible, if some one knows this pls help me thanks in adavance...
-
Hi all, How to call a C# method from a javascript. for example i am fetching a document.activeElement.value and i want to send this value to the C# method. Is it possible, if some one knows this pls help me thanks in adavance...
you can share this value via hidden control as d@nish said else if you really want to call C# method from javascript then call it like this
<%# serverMethod() %>
-
Hi all, How to call a C# method from a javascript. for example i am fetching a document.activeElement.value and i want to send this value to the C# method. Is it possible, if some one knows this pls help me thanks in adavance...
You can easily call server side static method, pass some value to it and get the returned value on your page without page postback. You can write a static Method in your Code-File with:
[System.Web.Services.WebMethod]
public static string MyMethod(string value)
{
return SomeString;
}Use Script Manager with PageMethods Enabled.
Now you can call your server side method with:
PageMethods.MyMethod(valueToPass, ChangeDDLValue, EnableDDL, dest);
for details please go Google about Ajax PageMethods. Hope this will help
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
You can easily call server side static method, pass some value to it and get the returned value on your page without page postback. You can write a static Method in your Code-File with:
[System.Web.Services.WebMethod]
public static string MyMethod(string value)
{
return SomeString;
}Use Script Manager with PageMethods Enabled.
Now you can call your server side method with:
PageMethods.MyMethod(valueToPass, ChangeDDLValue, EnableDDL, dest);
for details please go Google about Ajax PageMethods. Hope this will help
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
Hi Thanks a lot, I am using windows application which adds the scripts dynamically using BHO object and identifies the click even of the link.and actually i cant create the files in local disk from javascript(because of the security issues) so i thought of calling a c# method. then i realized that it cant be done.but we can call a webservice which can manipulate my data from javascript. Once again thanks for the solution.