Link to home
Start Free TrialLog in
Avatar of ANAT2403
ANAT2403Flag for Israel

asked on

hide the lines of VIEWSTATE in view source of a page

Hi,
In asp.net 2.0 with C# I want then when I will look at the running page in the browser and make view source I will not see the VIEWSTATE  word  appears at all.
I see  this situation in other sites. How this is done?
Anat
Avatar of slado2
slado2

Just don't use VIEWSTATE unless you have to.
Avatar of ANAT2403

ASKER

Hi,

I did not use it . It is created automatically and I don't know what cause it? This is what I want to understand.
Thankyou
anat
SOLUTION
Avatar of slado2
slado2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
I understand it now much better. Just one more question:
I don't use a gridview but I do use an asp: repeater control. and I have event in the databound of this.
How the repeater work with the viewstae if at all?
And also how the menu control and masterpage work or use the view state.
Thankyou
Anat
Viewstate is most important when you have input controls and do things that changes data and do things that require the page to "remember" values between postbacks.
If your repeater doesn't act as an "edit" form, then turning viewstate off should be ok.
It's not something I'd recommend be done globally (in web.config).
Easiest thing to do is disable it and test to see if you notice differences.
Correct. If in doubt, simply enable/disable viewstate to notice the difference.
Hi everybody,
I made a test and discovered strange things:
I took my web site and and made 4 tests:
1. I put enableviewstate=false in one of the content pages.
2. I did 1 + enableviewstate=false  in master page
3. I put <pages enableViewState="false"  /> in web.config with and without 1+2
4. I put in each server control in a content page enableviewstate=false  
results:
in all tests when I looked at view source I see that
input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTI0NzcwMjk1......
was in a smaller size but still it remains big and did not disappear.
only test 1 did the job. all the other tests did not have any affect.
As I render my page in each loading I don't need the viewstate and I want to disabe it.
How is it done?