473,721 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

viewstate big

Hi

How can i reduce the viewstate for my asp.net application. It is getting
very large now. What is a good solution?

thanks

N
Jun 11 '07 #1
12 1923
re:
!How can i reduce the viewstate for my asp.net application.

<%@ Page Language="C#" EnableViewState ="false" %>

or

<%@ Page Language="VB" EnableViewState ="false" %>

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Nick C" <be****@gmail.c omwrote in message news:eX******** ******@TK2MSFTN GP02.phx.gbl...
Hi

How can i reduce the viewstate for my asp.net application. It is getting very large now. What is a
good solution?

thanks

N

Jun 11 '07 #2
Hello Nick,

just turn viewstate off for the controls.
In case of grid, consider avoid using datagrid and switch to gridview

See there http://msdn.microsoft.com/msdnmag/is.../10/ViewState/
---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

NCHi
NC>
NCHow can i reduce the viewstate for my asp.net application. It is
NCgetting very large now. What is a good solution?
NC>
NCthanks
NC>
NCN
NC>
Jun 11 '07 #3
Be careful, in many cases viewstate needs to be enabled. You can set
EnableViewState ="false" on the page level and EnableViewState ="true" for
individual controls that need it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
re:
!How can i reduce the viewstate for my asp.net application.

<%@ Page Language="C#" EnableViewState ="false" %>

or

<%@ Page Language="VB" EnableViewState ="false" %>

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Nick C" <be****@gmail.c omwrote in message
news:eX******** ******@TK2MSFTN GP02.phx.gbl...
>Hi

How can i reduce the viewstate for my asp.net application. It is getting
very large now. What is a good solution?

thanks

N


Jun 11 '07 #4
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:uQ******** ******@TK2MSFTN GP04.phx.gbl...
Be careful, in many cases viewstate needs to be enabled. You can set
EnableViewState ="false" on the page level and EnableViewState ="true" for
individual controls that need it.
That's what I do...
--
http://www.markrae.net

Jun 11 '07 #5
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:a2******** *************** ****@msnews.mic rosoft.com...
In case of grid, consider avoid using datagrid and switch to gridview
Yes indeed - and there are many other good reasons to prefer GridView to
DataGrid...
--
http://www.markrae.net

Jun 11 '07 #6
re:
!Be careful, in many cases viewstate needs to be enabled.

Which cases *need* viewstate ?

I've never missed viewstate because I never program against the viewstate.

I prefer alternate methods of persisting the page/control info viewstate persists.
Viewstate is only one of several ways to persist page/control info you're interested in.

Viewstate contains all of a page's information *except* the data
which is available in the Request.Form collection, (PostData).

ASP.NET automatically populates control values with the data from Request.Form,
however, and I prefer using Session values to persist other types of data.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in message
news:uQ******** ******@TK2MSFTN GP04.phx.gbl...
Be careful, in many cases viewstate needs to be enabled. You can set EnableViewState ="false" on
the page level and EnableViewState ="true" for individual controls that need it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>re:
!How can i reduce the viewstate for my asp.net application.

<%@ Page Language="C#" EnableViewState ="false" %>

or

<%@ Page Language="VB" EnableViewState ="false" %>

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
============== =============== =========
"Nick C" <be****@gmail.c omwrote in message news:eX******** ******@TK2MSFTN GP02.phx.gbl...
>>Hi

How can i reduce the viewstate for my asp.net application. It is getting very large now. What is
a good solution?

thanks

N




Jun 11 '07 #7
I do use viewstate for persisting, mostly for storing small pieces of data
like boolean and integer properties. But in this aspect you are right, you
can persist data in other ways.

What viewstate is indeed necessary for is keeping control state between
postbacks. A simple example: item selection in a dropdown list. With
viewstate disabled you won't know what item is selected. And you will have
to re-populate the ddl on every postback.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:ua******** ******@TK2MSFTN GP05.phx.gbl...
re:
!Be careful, in many cases viewstate needs to be enabled.

Which cases *need* viewstate ?

I've never missed viewstate because I never program against the viewstate.

I prefer alternate methods of persisting the page/control info viewstate
persists.
Viewstate is only one of several ways to persist page/control info you're
interested in.

Viewstate contains all of a page's information *except* the data
which is available in the Request.Form collection, (PostData).

ASP.NET automatically populates control values with the data from
Request.Form,
however, and I prefer using Session values to persist other types of data.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message
news:uQ******** ******@TK2MSFTN GP04.phx.gbl...
>Be careful, in many cases viewstate needs to be enabled. You can set
EnableViewStat e="false" on
the page level and EnableViewState ="true" for individual controls that
need it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:%2******* *********@TK2MS FTNGP02.phx.gbl ...
>>re:
!How can i reduce the viewstate for my asp.net application.

<%@ Page Language="C#" EnableViewState ="false" %>

or

<%@ Page Language="VB" EnableViewState ="false" %>

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
============= =============== ==========
"Nick C" <be****@gmail.c omwrote in message
news:eX****** ********@TK2MSF TNGP02.phx.gbl. ..
Hi

How can i reduce the viewstate for my asp.net application. It is
getting very large now. What is
a good solution?

thanks

N




Jun 11 '07 #8
Hello Eliyahu,

For such cases the ControlState was introduced in ASP.net 2.0, where all
critical info can be persisted even if viewstate is turned off

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

EGI do use viewstate for persisting, mostly for storing small pieces
EGof data like boolean and integer properties. But in this aspect you
EGare right, you can persist data in other ways.
EG>
EGWhat viewstate is indeed necessary for is keeping control state
EGbetween postbacks. A simple example: item selection in a dropdown
EGlist. With viewstate disabled you won't know what item is selected.
EGAnd you will have to re-populate the ddl on every postback
EG>
Jun 11 '07 #9
Juan,
>I've never missed viewstate because I never program against the viewstate.
So, How do you manage (without viewstate) to track declarative and
dynamic changes to the properties of server controls?
>I prefer alternate methods of persisting the page/control info viewstate persists.
Viewstate is only one of several ways to persist page/control info you're interested in.
What are such alternate methods?
>ASP.NET automatically populates control values with the data from Request.Form,
however, and I prefer using Session values to persist other types of data.
True, as long as the controls implement IPostBackDataHa ndler
interface. But somehow I'am not quite sure where do you persist the
controls properties state without viewstate

I am not trying to be nit picky, curious to know how you are managing
things differently.

Raaj

On Jun 11, 8:43 am, "Juan T. Llibre" <nomailrepl...@ nowhere.com>
wrote:
re:
!Be careful, in many cases viewstate needs to be enabled.

Which cases *need* viewstate ?

I've never missed viewstate because I never program against the viewstate.

I prefer alternate methods of persisting the page/control info viewstate persists.
Viewstate is only one of several ways to persist page/control info you'reintereste d in.

Viewstate contains all of a page's information *except* the data
which is available in the Request.Form collection, (PostData).

ASP.NET automatically populates control values with the data from Request..Form,
however, and I prefer using Session values to persist other types of data.

Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
=============== =============== ========"Eliyah u Goldin" <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te in message

news:uQ******** ******@TK2MSFTN GP04.phx.gbl...
Be careful, in many cases viewstate needs to be enabled. You can set EnableViewState ="false" on
the page level and EnableViewState ="true" for individual controls that need it.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
re:
!How can i reduce the viewstate for my asp.net application.
<%@ Page Language="C#" EnableViewState ="false" %>
or
<%@ Page Language="VB" EnableViewState ="false" %>
Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
=============== =============== ========
"Nick C" <bef...@gmail.c omwrote in messagenews:eX* *************@T K2MSFTNGP02.phx .gbl...
Hi
>How can i reduce the viewstate for my asp.net application. It is getting very large now. What is
a good solution?
>thanks
>N- Hide quoted text -

- Show quoted text -

Jun 11 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
21644
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
3
2648
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
10
2275
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and disable the session state in Web.Config the VIEWSTATE variable is still maintained and stores some values. Can anyone tell what those values are for, i.e what other info is stored in VIEWSTATE other than the session ID and the control values ?
1
1769
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra properties declared on it over and above that provided by the textbox. As I understand it, part of the process to make this work is, in the property accessor's for the properties that you wish to persist you add
7
2042
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get them, or how do we get that value? I always have to set the ViewState("FirstName") = txtBox.text myself before a postback is done, otherwise, the value of ViewState("FirstName") is always empty; there doesn't seem to be a way to retrieve that...
3
4572
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and set textboxes, radio buttons, etc - that viewstate is fine. Then I have a linkbutton that does a Server.Transfer over to Page2.aspx. When I Server.Transfer back to Page1.aspx, the viewstate info is lost. I ran across another example of this last...
9
1870
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct the server to remember a variables state *without* having to go through the rigmarole of saving and loading to and from the Session state manually or similar workaround for any Types (including custom types) in exactly the same way web controls...
6
2058
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when page gets post back it gives following error Failed to load viewstate. The control tree into which viewstate is
6
4450
by: paul.hester | last post by:
Hi all, Does anyone know why the ViewState would be empty? When I'm receiving a postback, I can access a posted value using controlName.Value but not ViewState. I have EnableViewState set to true in my master page and content page. Thanks,
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.