Change __VIEWSTATE to something else

  • Thread starter Thread starter Ivan Gasparetto
  • Start date Start date
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
 
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>




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
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)
 
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 ).




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
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)
 
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
 
Back
Top