Change __VIEWSTATE to something else

I

Ivan Gasparetto

Is it possible to change the __VIEWSTATE id?
The reason is we shouldn't have any id starting with underscores on
XHTML pages.

Thank you
 
J

Juan T. Llibre

re:
!> The reason is we shouldn't have any id starting with underscores on XHTML pages.

Who told you that ?
IDs starting with *double* underscores are perfectly acceptable in XHTML.

Check the validity of my ASP.NET FAQ's pages :

http://asp.net.do/faq/default.aspx

Here's the link to the W3C's validator :
http://validator.w3.org/check?uri=h...(detect+automatically)&doctype=Inline&group=0

Here's the response by the W3C's validator: "This Page Is Valid XHTML 1.0 Transitional!"

Now, check "View Source" for that page, and see that the page *does* include a "__VIEWSTATE" id :

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTA1MDI3ODMwMWRkjOh6z8CUeDcuYjV3L6BQzzSZL7Q=" />

The key, of course, is that "__VIEWSTATE" has TWO underscores. <g>
 
B

bruce barker

yes, you have two options:

1) switch to MVC which doesn't generate any any viewstate or unwanted markup.

2) override PageStatePersister and create your own hidden field. google for
examples.

-- bruce (sqlwork.com)
 
J

Juan T. Llibre

Bruce, why override, if ID's which start with an underscore are perfectly acceptable in XHTML ?

See my just-sent reply to Ivan.
 
J

Juan T. Llibre

re:
!> the latest html 4.01 spec still does not allow an id to start with an "_".
!> see: http://www.w3.org/TR/html401/types.html#h-6.2

Sure, but that's the spec for HTML 4.01, not the spec for XHTML.

That's why the "eXtensible" specs were added to HTML, right ?

;-)

I know that *frame names* cannot begin with an underscore in both html and xhtml
( probably so there's no confusion with reserved names like "_top", "_blank", "_parent", etc ).
 
B

bruce barker

no. the thought was that html would be easier process (or parse) if it
was xml compliant (an xml reader could be used). its was based on a
subset of html 4.0 xhtml is dead (no more versions). the W3C is
replacing it with html 5.0

note: safari and firefox are already adding 5.0 features.

-- bruce (sqlwork.com)
 
M

Marc

Ivan Gasparetto said:
Is it possible to change the __VIEWSTATE id?
The reason is we shouldn't have any id starting with underscores on
XHTML pages.

Google around and you'll find it's valid... however the FORM NAME attribute
is not. There is something you can add to webconfig to make ASP.NET generate
XHTML compliant output...
<system.web>
<!-- other elements here -->
<xhtmlConformance
mode="Strict" />
</system.web>

Copied form http://msdn.microsoft.com/en-us/library/ms178159(VS.80).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
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top