Hidden __viewstate form field changes page layout

M

Me

Is there anyway to control the style/layout of this field?

..NET doesn't generate an ID for it so you can create a style for it or
manipulate it in code.

I've looked on MSDN etc. but can't find the answer.

Thanks in advance,
RWK
 
S

Steven Cheng[MSFT]

Hi RWK£¬


Thanks for posting in the community!
From your description, you'd like to do some operations do some operations
on the <input type=hidden name="__VIEWSTATE" ..> field of the ASP.NET web
page and you found the tag not have a "id" property so that you can't
manage to control it,yes?
If there is anything I misunderstood, please feel free to let me know.

Based on my research, the <input type="hidden" name="__VIEWSTATE" > is a
certain hidden field the ASP.NET use to store the PAGE and its controls'
states info.
Here is the detailed infos in MSDN:
#Taking a Bite Out of ASP.NET ViewState
http://msdn.microsoft.com/library/en-us/dnaspnet/html/asp11222001.asp?frame=
true

It it generated and set value when the page is rendered out to client. So
there're no interface for us to manually modify it as a normal html control
because it is not visible in the Serverside page's control collection.(You
may turn on the page's trace to have a proof). Also, I'm not sure why you'd
like to manipulate the "__VIEWSTATE" tag since it is a unvisible element in
client response. Would you please give me some further infos on your
requriment?

And If you do want to modifiy it, here are some particular approachs to do
it:
1. Use a Custom Form class to replace the HtmlForm class and override the
page's Load and Save Viewsate's function, you may view the following tech
article for detailed description on this:
#Valid XHTML within .NET
http://www.liquid-internet.co.uk/content/dynamic/pages/series1article1.aspx

2. Use the ASP.NET response filter to do some modification after the
ASP.NET render out the page and before it is send to client side:
Here are some tech articles on using the Response Filter:
# Producing XHTML-Compliant Pages With Response Filters
http://www.aspnetresources.com/articles/HttpFilters.aspx

#Reduce The Size Of Your ASP.NET Output
http://www.codeproject.com/aspnet/WhitespaceFilter.asp

Please check out the preceding suggestions. If you have further questions
or need any assistance, please feel free to post here.




Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

-------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top