c# - Call a Javascript Method from code-behind Web Method -
i have web method in code behind:
[system.web.services.webmethod] public static string getstatedata(string state) { //this want call javascript method "getitems" }
i have javascript method retrieves values me , want use 1 of values in web method
function getitems() { var variable1= $("#<%=item1.clientid %> input:checked"); var variable2= $("#<%=item2.clientid %>").val(); return [variable1.text(), variable2.val(), variable2];}
i've searched ways call javascript method web method every time search results in how call web method javascript.
i did find done code-behind of silverlight project , when tried adding correct reference code-behind wasn't there
var result = htmlpage.window.invoke("getitems");
is there reference i'm missing?
thanks response
you can't that. calling webmethod through ajax. sending small pieces of information static method on server knows nothing specific page object (that isn't static).
what want send values , data in ajax call webmethod. not making full postback know nothing current state of page except pass paramaters webmethod.
either send information in first place or return kind of flag when want information , client make ajax call function information , let continue there.
Comments
Post a Comment