views:

89

answers:

1

According to the MSDN documentation, ScriptManager.GetStateString() "Retrieves a string that contains key/value pairs that represent the state of the Web page."

When I call the method it returns what appears to be a hashed string - how do I parse this into something useful? What exactly is returned by the GetStateString method?

EDIT: I notice that if I submit the form on the page or append data to the querystring, the value returned by GetStateString does not change. "Page state" apparently doesn't include this sort of state data?

UPDATE: When I set ScriptManager.EnableSecureHistoryState = false the hashed value is replaced with an empty string. Apparently if EnableSecureHistoryState = true, the value returned by GetStateString is encrypted and hashed.

+1  A: 

GetStateString() returns the state from the history hash.

The history hash is your answer to enable the browser back/forward buttons in your Ajax application. It records your entries so you can go back and forward.

Check out the AddHistoryPoint method for adding data to the history hash and check this blog post for example usage.

The reason you get a hashed response when ScriptManager.EnableSecureHistoryState = true is because the history state hash table is empty, but not NULL. It is an object which can still be serialized and encrypted.

If the state hash is NULL or empty, an empty string will be returned, and I suspect this to be your case. You haven't added a history point.

Mikael Svenson