Asp.net public static methods that are marked with the attribute [webmethod] are available as Ajax calls in JavaScript. Unfortunately these methods can't access the Page object or any non-static values or objects.
The solution? Create one or more static properties and use them to store the data you need in your session.
static IAccount account
{
get
{
return (IAccount) HttpContext.Current.Session["MyPageAct"];
}
set
{
HttpContext.Current.Session["MyPageAct"] = value;
}
}
Now you can initialize this property in your page load event and because it's static it can also be accessed from your web method.

0 - What do you think?:
Post a Comment