Click here to Skip to main content
14,733,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi i want to pass a parameter from javascript to server method
how can i do this?
for example below code

var myParameter=3369;
alert("<%=myServerMethod('myParameter')%>")

and my server method is
public string myServerMethod(int id)
{
 return (id+1).toString();
}

thanks in advance
Posted
Updated 7-Jun-13 2:58am
v2
Comments
NarasimhaMurthy 7-Jun-13 8:15am
   
Are you using AJAX or JQuery?
mhd.sbt 7-Jun-13 8:18am
   
no

You will have to use native AJAX or JQuery's $.ajax() method.

This[^] is a useful article to get started with jQuery's $.ajax() method.

And This[^] article is about using pagemethod with a ScriptManager.

BTW, if you just want to use your JavaScript variable in the code behind, you can also store it into hidden field and access it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900