Web apps with ASP. NET Core. Mobile apps with Xamarin. Microservices with Docker Containers. Modernizing existing. NET apps to the cloud.
May 7th, Read next. Immo Landwerth May 8, Relevant Links. Please do not post code, scripts or snippets. Required Invalid Email Address. Security code:. Required Invalid security code.
I declare, I accept the site's Privacy Policy. Add Comment. Disclaimer : The code samples and API available at www. You are free to use it for commercial as well as non-commercial use at your own risk, but you cannot use it for posting on blogs or other tutorial websites similar to www. To overcome this intrinsic limitation of Web programming, the ASP. NET page framework includes several state-management features to preserve page and control values between round trips to the Web server.
One of these features is view state ASP. By default, the ASP. NET page framework uses view state to preserve page and control values between round trips. When the HTML for the page is rendered, the current state of the page and values that must be retained during postback are serialized into baseencoded strings.
They are then put into a hidden field or fields in the page. You can access view state in your code by using the page's ViewState property. It is easy for a malicious user to see and modify the contents of a hidden field. For more information about how to secure view state data, see Securing View State later in this topic. For recommendations about when you should store information in view state, see ASP. You can change the default behavior and store view state in another location such as a SQL Server database by implementing a custom PageStatePersister class to store page data.
For an example of how to store page state in a stream instead of in a hidden field, see the example for the PageStatePersister class. View state provides state information for a specific ASP. NET page. If you need to use information on more than one page, or if you need the information to persist across visits to the Web site, you must use another method for maintaining state.
You can use application state, session state, or profile properties. View state information is serialized into XML and then encoded by using base encoding, which can generate large amounts of data. When the page is posted to the server, the contents of view state are sent as part of the page postback information.
If view state contains a large amount of information, it can affect performance of the page. Test the performance of your pages by using typical data for your application to determine whether the size of view state is causing performance problems.
For alternatives to using view state, see ASP. If you do not have to store control information for individual controls, you can disable view state for a control. If a control on a page is refreshed from the data store on each postback, you can turn view state off for that control in order to reduce the size of view state.
For example, you might turn view state off for a control such as the GridView control. Even when you explicitly turn view state off, a hidden field is still sent to the browser to indicate that postback is occurring for the page. Another consideration is that if the amount of data in a hidden field becomes large, some proxies and firewalls will prevent access to the page that contains them.
Because the maximum allowed amount can vary with different firewall and proxy implementations, large hidden fields can cause intermittent problems. If the amount of data that is stored in the ViewState property exceeds the value specified in the page's MaxPageStateFieldLength property, the page splits view state into multiple hidden fields. This reduces the size of individual hidden fields below the size that firewalls reject.
Some mobile devices do not allow hidden fields at all. Therefore, view state will not work for those devices. For more information and alternatives, see ASP. Ask a question. Quick access. Search related threads. Remove From My Forums. Asked by:. Archived Forums. Sign in to vote. Thursday, March 2, PM. User posted Hey, Maintaining callback state for what? Value; NC Friday, March 3, AM. Saturday, March 4, AM. User posted I have no idea what you mean since, in my experiences, an asp:TextBox will maintain it's state on PostBack regardless of what you do client-side.
Now you will have problems with Labels, Tables, ListBoxes, etc since they don't. Sunday, March 5, AM. User posted an asp:TextBox will maintain it's state on PostBack regardless of what you do client-side. User posted You cannot change ViewState client-side. Monday, March 6, AM. User posted Ok thanks for the answer, I will try this way.
0コメント