Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I access the ViewState of the current page using HttpContext?

How could I access the ViewState of the current page using HttpContext

I have a ViewStateUtil class that I'd need to implement:

    public static T GetViewState<T>(ViewStateKey viewStateKey)
    {
       // how to implement it?! HttpContext.Current...?
    }
like image 680
The Light Avatar asked Jan 17 '26 09:01

The Light


1 Answers

    private static T GetViewState<T>(string name)
    {
        return (T) ((BasePage)HttpContext.Current.CurrentHandler).PageViewState[name];
    }

I added a new PageViewState property and let all my pages inherit from my BasePage to expose ViewState then being able to get or set it.

like image 64
The Light Avatar answered Jan 21 '26 08:01

The Light