Slow page load due to viewstate

J

Jman

I have a selection window, here are some dropdownlist if i click on an
item in a dropdownlist the page reloads itself an puts the selected
item in a textbox. Then i can search on the value in the textbox.
The values in the dropdownlist is variable. In one of the dropdownlists
there are lots of values and my viewstate is very large. My page is
almost 3 mb. This is way too much to load every time.
I can not set my viewstate to false because then the page doesn't work
anymore as it should be. (The textbox doesn't fill and my dropdownlist
becomes empty).

I 'm searching for a way to disable the viewstate and not to do a
postback every time i want to change something in my page.
The person who made this page has moved to another company so i'm
practically new to this.

Can someone give me some way to fix my problem?
Thanks for the help.
 
C

Cowboy \(Gregory A. Beamer\)

You have a couple of choices to trim down your page.

1. Use Ajax to refresh elements on the page when a dropdown item is selected
2. Use a wizard control (or panels - have to use panels in 1.x) to switch
out elements. Elements that are not visible do not re-download.

The third choice is to re-architect the page, and perhaps the application,
to change flow.
 
E

Eliyahu Goldin

Not everything in a web application has to be done on server side. You can
do many things on client side without round trips to the server. You need to
know a bit of javascript and html for this.

If upon a selection in the dropdown you just need to fill up a textbox, it
is a typical client side task. If you need also to do something with the
database, you must go to the server for this, everything depends on your
specific requirements. You may find an compromise in Ajax.

You can disable/enable viewstate for every control separately with the
EnableViewState property.

Another option for reducing the viewstate size is to disable it for the
viewstate-hungry controls and reload them on every postback on server side.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top