viewstate

ASP.Net viewstate questions on form postbacks

北慕城南 提交于 2019-12-08 02:52:37
问题 Let's assume I have a very simple form, with a submit button and a dropdown list. When I change the list entry and hit submit, at what stage in the postback processing does the viewstate reflect my changed list entry? According to O'Reilly's Learning ASP.Net 3.5, there are two loads taking place-- one before form validation and another after (diagram on page 266 for those with a copy). According to the diagram the viewstate is loaded during the first load stage, before the validation. I

Minimize ViewState with TreeView

混江龙づ霸主 提交于 2019-12-08 02:29:47
问题 Any practical tips/tricks on how to do that? It doesn't seem that there is a lot of information about how to do that. I am loading data from the database into TreeView and the max number of nodes will be around 100. I am still interested in minimizing the ViewState. I will also be adding and deleting nodes dynamically (though the user interaction). Thanks! PS: I am using asp.net 2.0, c#, webforms (so don't give me tips that relate to to ASP MVC only) 回答1: here is a wonderful way to just get

Inconsistent behavior with AJAX and ViewState in .NET

匆匆过客 提交于 2019-12-08 02:15:02
问题 I'm finding that hitting the "Refresh" button on my browser will temporarily screw up the ViewState for controls inside an UpdatePanel. Here's my situation : I made a custom WebControl that stores values in the ViewState. I put this control inside an UpdatePanel. When I hit the "refresh" button on my browser, it will temporarily wipe out the values in ViewState. However, on the next postback, the values that were in the ViewState before I hit "refresh" magically reappear. This behavior screws

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

时光总嘲笑我的痴心妄想 提交于 2019-12-07 23:16:16
问题 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...? } 回答1: 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

Server-state serialization in a session in Mojarra

你。 提交于 2019-12-07 17:31:46
问题 Going through an abstract in a book, I came across this: On the server side, the state can be stored as a shallow copy or as a deep copy. In a shallow copy, the state is not serialized in the session. By default, JSF Mojarra uses shallow copy. I seriously couldn't understand this. Since in the above case, we will have- javax.faces.STATE_SAVING_METHOD set to server , and an input hidden field javax.faces.ViewState with a value somewhat like this "2870966362946771868:-8449289062699033744" .

Primefaces datatable selected row not working using viewscope

最后都变了- 提交于 2019-12-07 16:55:38
问题 I am using JSF 2.0 and Primefaces 3.4.2, I have a datatable populated using lazy load. When I view scope for managedbean, then datatable selectedRow gives null pointer exception. If I use session scope then I could get selectedRow in managedbean. I am using CDI Spring annotations for specifying scope. I have used this method to create view scope. Update 1 I have noticed another thing is using view scope when I paginate to second page and then comes back to first page, then I could get the

Detecting viewstate tampering

断了今生、忘了曾经 提交于 2019-12-07 16:48:31
问题 It has been seen in my asp.net project that the viewstate has changed. Is there anyway to check whether my ViewState has been tampered with? (ideally with C#) 回答1: The viewstate is signed with a machinekey (default servers mac) however if it's just the error you get then it could be a transmission error or similar (also if your running a farm make sure to set the same machine key on all machines) Also if your after security don't store sensetive information in the viewstate, save it in the

How to store an object in the viewstate?

家住魔仙堡 提交于 2019-12-07 10:10:38
问题 I am using EWS to develop my email client. I found that if I store ItemId in viewstate it will cause an exception says: Type 'Microsoft.Exchange.WebServices.Data.ItemId' in Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. If I store ItemId as string like: ViewState["itemId"] = id.ToString(); and then try to cast back, ItemId id = (ItemId)ViewState["itemId"]; it says I can not convert from string to

Saving a value to and reading from the viewstate

Deadly 提交于 2019-12-07 09:42:45
问题 I'm not too familiar with .NET, but I want to save a simple value (a number between 1 and 1000, which is the height of a particular div ) to the viewstate and retrieve it when the update panel reloads (either in the markup somewhere or with javascript). What is the simplest way to do this? This page gives me the following code: string strColor; if (Page.IsPostBack) { // Retrieve and display the property value. strColor = (string)ViewState["color"]; Response.Write(strColor); } else // Save the

viewStateEncryptionMode=“Always” not encrypting

大城市里の小女人 提交于 2019-12-07 09:34:01
问题 Due to some security concerns i need to enable View State Encryption. I have viewstate & viewstateMAC turned off but i need to encrypt the "control state" string that is included in the __VIEWSTATE form parameter. Currently my web.config looks like: <pages enableViewState="false" enableViewStateMac="false"> When i set the following, in cassini, my viewstate is encrypted: <pages enableViewState="false" enableViewStateMac="false" viewStateEncryptionMode="Always"> When i make the same change on