yes, you can make web method like.. you can create web service to call to server side code
[WebMethod]
public static String SetName(string name)
{
return "Your String"
}
and then call in javascript like..
PageMethods.SetName(parameterValueIfAny, onSuccessMethod,onFailMethod);
this also required
<asp:scriptmanager id="ScriptMgr" runat="server" enablepagemethods="true" xmlns:asp="#unknown"> </asp:scriptmanager>