Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > viewstate big

Reply
Thread Tools

viewstate big

 
 
Nick C
Guest
Posts: n/a
 
      06-11-2007
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


 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-11-2007
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Michael Nemtsev
Guest
Posts: n/a
 
      06-11-2007
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

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


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-11-2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-11-2007
"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      06-11-2007
"Michael Nemtsev" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) t.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

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-11-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>




 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-11-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in
> message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> 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" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> 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
>>>>
>>>
>>>

>>
>>

>
>
>



 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      06-11-2007
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

EG> I do use viewstate for persisting, mostly for storing small pieces
EG> of data like boolean and integer properties. But in this aspect you
EG> are right, you can persist data in other ways.
EG>
EG> What viewstate is indeed necessary for is keeping control state
EG> between postbacks. A simple example: item selection in a dropdown
EG> list. With viewstate disabled you won't know what item is selected.
EG> And you will have to re-populate the ddl on every postback
EG>


 
Reply With Quote
 
Raaj
Guest
Posts: n/a
 
      06-11-2007
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 IPostBackDataHandler
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" <(E-Mail Removed)>
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'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" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > 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" <(E-Mail Removed)> wrote in message
> >news:%(E-Mail Removed)...
> >> 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" <(E-Mail Removed)> wrote in messagenews:(E-Mail Removed). ..
> >>> 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 -



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments