VIEWSTATE hidden field.

Posted on 2004-08-17
Last Modified: 2010-04-07
Hi All,
I have an aspx page...
It is a search form, has adropdown list asp control with other controls.
The list items are filled from a database, the number of records returned are around 50 records.
The form has a button to post the data, when i click it, it didn't work, no posting...
When i minimize the number of records returned(number of list items), the form works successfully,,,
i think the reason is in the VIEWSTATE field, i think it can contains a fixed number of characters...
If this is what cause the problem, Is there any way to enlarge its size??
If not, please help, so i can know what the problem is?

Thankx in advanced
Question by:samjav

Accepted Solution

shovavnik earned 50 total points
ID: 11820907
Don't use the viewstate for large amounts of information.  It does have a limit and is intended for maintaining state, not data.

Use the session object.

Everywhere you have ViewState[], replace it with Session[].

If you can't use the session object, you'll have to persist your info in other ways.  First try using the session.
LVL 17

Assisted Solution

AerosSaga earned 50 total points
ID: 11820948
are you using view state during page unload?

Do not attempt to store ViewState information in the Page.Unload event. Although no error will be thrown, the information will not be stored. This is because by the time the Page.Unload event is fired, the HTML has already been created.



Author Comment

ID: 11821069
i meant the "__VIEWSTATE" hidden filed generated by the page when it is called.
This field has value of long increpted string.
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

LVL 17

Expert Comment

ID: 11821125
Heres a work around using java:


LVL 33

Assisted Solution

raterus earned 50 total points
ID: 11821142
The viewstate doesn't have a limit in size, but it does have it's drawbacks.  While it is great, realize that your users not only have to download that field, but also send it back to the server when they postback the form.  If you are storing large objects like a DataSet in it, your users are going be faced with a very slow page.  If you have large controls like a DataGrid on your page, that can fill up the viewstate quickly.
LVL 17

Expert Comment

ID: 11821166
and by the way it is not encrypted, but base64 encoded
LVL 17

Expert Comment

ID: 11821198

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question