Friday, 23 August 2013

How to store Data from static WebMethods into the ViewState

How to store Data from static WebMethods into the ViewState

Now I have done some research. I need to store some data that I have
retrieved from an ajax call to my WebMethod on my page into some place
where I can pull it back again anytime.
I thought at first that the ViewState would be the best option.
Unfortunately you cannot reference it in the same way you can in
non-static methods. Even if I make instance of the page to store it in the
ViewState, I believe that it would be de-instantiated at the end of the
method destroying whatever data I saved.
I need this data for the purpose of database calls that I am doing in
other WebMethods.
The basic method in my C# codebehind for my aspx page looks like this:
[WebMethod]
[ScriptMethod]
public static string populateModels(string[] makeIds)
{
}
So for example I need to save the selected makes to pull from for future
database calls. Since most of my boxes cascade in terms of filtering and
pulling from the database.

No comments:

Post a Comment