We help IT Professionals succeed at work.

hide the lines of VIEWSTATE in view source of a page

ANAT2403
ANAT2403 asked
on
1,424 Views
Last Modified: 2013-11-07
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
Comment
Watch Question

Commented:
Just don't use VIEWSTATE unless you have to.

Author

Commented:
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
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2007
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.

Commented:
Correct. If in doubt, simply enable/disable viewstate to notice the difference.

Author

Commented:
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?
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.