1. First Step :
Enable page method set to true, as shown here.
<asp:scriptmanager enablepagemethods="true" id="MainSM" runat="server" scriptmode="Release" loadscriptsbeforeui="true" xmlns:asp="#unknown">
2. Second Step :
use JavaScript function or AJAX alternately.
function InitializeRequest(path) {
PageMethods.SetDownloadPath(path);
}
3. Make a method or service to request from function (Step 2)
[System.Web.Services.WebMethod]
public static string SetDownloadPath(string strpath)
{
Page objp = new Page();
objp.Session["strDwnPath"] = strpath;
return strpath;
}