Groups | Blog | Home
all groups > asp.net > march 2007 >

asp.net : is there any way to avoid __VIEWSTATE hidden field in the page


reju
3/5/2007 10:04:11 PM
Hi,

I am not using view state.I disabled the view state, but this hidden
__VIEWSTATE variable and some text is coming when we are taking the
view source.Is there any way to remove this variable?

Reju
Adlai Maschiach
3/5/2007 10:52:40 PM
Hi

You just cant get rid completely of the __VIEWSTATE field, it will always
contain a few bytes that are used internally and dont relate to your
control's state.

Adlai
-------------------------------------
If my answer helped you please press "Yes" bellow

אם תשובה זו עזרה לך, אנא הצבע "כן"

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/


[quoted text, click to view]
Kevin
3/5/2007 11:21:40 PM
[quoted text, click to view]

You can override two page methods (available in ASP.NET 2.0) -
Page.LoadPageStateFromPersistenceMedium() and
Page.SavePageStateToPersistenceMedium(viewState) to store viewstate in
Session / Cache / SQL with the need to send it to the client (by
default). More info can be found here:

http://www.codeproject.com/aspnet/PersistentStatePage.asp
Juan T. Llibre
3/6/2007 12:00:00 AM
Set EnableViewState to false in the page directive or in the app's web.config.

Per page (in directive) : <%@ Page EnableViewState="False" ... %>
Per application (in web.config) : <Pages EnableViewState="false" ... />

You can also disable it for individual controls.

Doing that will reduce viewstate to a very small size.

If you want to disable it completely ( remove it ), see Natty Gur's sample code :

http://weblogs.asp.net/ngur/archive/2004/03/08/85876.aspx




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/
===================================
[quoted text, click to view]


Mark Rae
3/6/2007 12:00:00 AM
"Adlai Maschiach" <AdlaiMaschiach@discussions.microsoft.com> wrote in
message news:46623DB3-0C6E-4EFB-AD73-FC8DA1889C20@microsoft.com...

[quoted text, click to view]

Yes you can: http://weblogs.asp.net:80/ngur/archive/2004/03/08/85876.aspx

reju
3/6/2007 2:47:27 AM
[quoted text, click to view]
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"reju" <rejumgeo...@gmail.com> wrote in me=
ssage
[quoted text, click to view]

Hi Juan,
when I override the SavePageStateToPersistenceMedium method my submitt
buttons are not working,
I can't navigate to next page
Reju
reju
3/6/2007 2:49:16 AM
[quoted text, click to view]
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"reju" <rejumgeo...@gmail.com> wrote in me=
ssage
[quoted text, click to view]

Hi Juan,
when I override the SavePageStateToPersistenceMedium method my submit
buttons are not working,
I can't navigate to next page
Reju
Juan T. Llibre
3/6/2007 7:44:34 AM
You have to weigh the pros and cons of disabling Viewstate
and determine whether disabling it is a good policy for you.




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/
===================================
[quoted text, click to view]

Hi Juan,
when I override the SavePageStateToPersistenceMedium method my submit
buttons are not working,
I can't navigate to next page
Reju

AddThis Social Bookmark Button