开发者

How do I use ScriptManager.GetStateString()?

开发者 https://www.devze.com 2022-12-21 09:53 出处:网络
According to the MSDN documentation, ScriptManager.GetStateString() \"Retrieves a string that contains key/value pairs that represent the state of the Web page.\"

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开发者_Go百科 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消