Questions tagged [viewstate]

ViewState is the mechanism that allows form field values to be preserved across page postbacks.

View state refers to the page-level state management mechanism utilized by component based frameworks, such as Microsoft and , Oracle and so on.

References

1589 questions
16
votes
6 answers

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
Nasser Hadjloo
  • 12,312
  • 15
  • 69
  • 100
16
votes
5 answers

Setting ViewStateUserKey gives me a "Validation of viewstate MAC failed" error

I have the following in my BasePage class which all my ASPX pages derive from: protected override void OnInit(EventArgs e) { base.OnInit(e); ViewStateUserKey = Session.SessionID; } I also have a machineKey set in Web.config. I don't think…
Druid
  • 6,423
  • 4
  • 41
  • 56
16
votes
6 answers

What does the __VIEWSTATE hold?

I'm sorry for maybe making such a basic question but in ASP.NET websites what does the __VIEWSTATE input field represent? Also, is there any way to compute it's value (based on the values of other form fields)? EDIT I understand that __VIEWSTATE, as…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
16
votes
3 answers

How to disable ViewState for a .aspx page?

I need to completely disable ViewState for a .aspx page inside my web application. I have gone through different blogs and what I understand is that we must set <%@ Page EnableViewState="false" ...%>, but this is not working. Is this enough to…
Mridul Raj
  • 1,001
  • 4
  • 19
  • 46
16
votes
3 answers

ViewState invalid only in Safari

One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error. This appears to only happen in Safari.…
Anthony Main
  • 6,039
  • 12
  • 64
  • 89
15
votes
6 answers

How do I turn off viewstate for good?

Coming from a PHP background I love using clean URLs to grab data from one service to another. However, on some of my ASP.NET projects I get the horrible ViewState parameter in my URLs. Is there a way to turn this off globally? What affect will this…
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
15
votes
9 answers

Failed to load viewstate. Happening only occasionally. Tough to recreate

Details of Error are given below. This error happens only occasionally / rarely / sometimes and there aren't any steps to reproduce it. How can I know which Control is throwing this Viewstate error? Error Message: Failed to load viewstate. The…
Roberto Carlos
15
votes
8 answers

Why would you ever use asp.net's ViewState storage object over the Session storage object?

Other than because session storage is session-global to more than one page, why would you ever want to use the viewstate to hold values? It seems kind of ridiculous to send any kind of information other than a few small query string like values,…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
15
votes
9 answers

Problem with dynamic controls in .NET

Problem with dynamic controls Hello all, I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. …
user27293
  • 163
  • 1
  • 1
  • 5
13
votes
3 answers

hidden field vs viewstate

What is the difference when using Hidden field vs View state? When to use each one ? Which one more secure? Which is better in performance? what are the alternatives?
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
13
votes
5 answers

Tracking state using ASP.NET AJAX / ICallbackEventHandler

I have a problem with maintaining state in an ASP.NET AJAX page. Short version: I need some way to update the page ViewState after an async callback has been made, to reflect any state changes the server made during the async call. This seems to be…
Rex M
  • 142,167
  • 33
  • 283
  • 313
13
votes
8 answers

Enable ViewState for few controls and disable for others/page

When I disable ViewState for the page. It does not allow any other control to use ViewState .. even if I set EnableViewState="true" for that particular control .. is it possible to enable ViewState for a control when ViewState is disabled for the…
Zuhaib
  • 1,420
  • 3
  • 18
  • 34
13
votes
2 answers

Data Persistence across ASP.NET postbacks

Context: I've often been in situations where our ASP.NET pages would have to show data to the user on a GridView, let him change it as he pleases (Textbox on cells) and only save it to the database when he actually hits the "Save Button". This data…
Mateus Schneiders
  • 4,853
  • 3
  • 20
  • 40
13
votes
2 answers

How to store list of object into ViewState

I have a list of type List. I want to store it in ViewState. How this can be done? private List JobSeekersList { get; set; }
user1613523
  • 963
  • 2
  • 7
  • 6