Hi,

I am new to asp.net development, and i'm currrently trying to develop my first web application. My question relates to making my site compliant with html coding standards. To test the generated html from an asp page I put together simple master and content pages with only some text and a button in the content pane. However, in the html this generated the below line in the source

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjQyNDIwNTI0D2QWAmYPZBYCAgMPZBYCAgEPZBYCAgUPPCs
ADQBkGAEFI2N0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkR3JpZFZpZXcxD2dk9Yu8B
dQuYa4ficS70xgINaIrmYs=" />

When i then added more to the page, such as gridviews and dynamically built menus etc, this string became enormous making the html very messy. I am basically wondering is there anyway I can hide this code so that it doesnt show in the source?

Kindest Regards,

David.

Why does it matter? And no.

This is due to the fact that Viewstate Property is enabled for Server Controls. It means that the value entered in a textbox and other controls for which Viewstate is enabled, is not lost when the Page is refreshed. The Viewstate acts like a hidden variable (in classic ASP) which stores the value of the textbox and replaces the value in the textbox when the page refreshes. This is the same principal at work when you enter a User and a wrong PWD. The User values is displayed again, but not the PWD-because it is not stored in Viewstate.

PS: Viewstate is encrypted. Thats the encrypted values you are seeing.

Member Avatar for rajarajan2017

Thanks Guys it should be very helpful tips for me too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.