I’m trying to convert a game I made (WindowsFormApplication) to an ASP.NET page.
My Problem is that I have a lot “private” variables in my WindowFormApplication and those variables are important for the game. But when after I Declare all my variables (in my Page_Load), they turn null no matter what I do(click a button, refresh the page).
Is there anyway to save my variables between buttons (other than Session, because I’d have to create like 6 more sessions)
You will need to save your variables in the
ViewStateobject:If you already have a property then you can just use the
ViewStateto hold the value, such as:If your value needs to be available in the whole application (but specific to the current user), you can use
Sessioninstead ofViewState.If you are worried about people messing with the ViewState then here are two options: