ASP.NET 2.0, it seems to wrap a div around the hidden form fields

T

Thor W Hammer

In ASP.NET 2.0, it seems to wrap a div around the hidden form fields such as
__ViewState. How do you override this rendering?
 
B

Bruce Barker

please report it as a bug if enough of us do, maybe MS will fix it (it
causes all kinds of layout problems).

the only fix is a post processing httphandler that strips the divs out. i
haven't written one yet, but i'm close.


-- bruce (sqlwork.com)
 
G

Greg Burns

http://www.aspnetpro.com/newsletterarticle/2005/11/asp200511de_l/asp200511de_l.asp

"ASP.NET 2.0 defaults to XHTML 1.1, but you can also opt for XHTML 1.0
Strict or Transitional. The rendering engine of some controls has been
reworked to make them produce compliant output. As a result, in ASP.NET 2.0,
each control's markup includes a closing tag. Furthermore, the viewstate
hidden field comes surrounded by a <div> tag and the form is only identified
by the ID attribute."

Sounds like they did this for a reason.

Greg
 
E

Erik Funkenbusch

In ASP.NET 2.0, it seems to wrap a div around the hidden form fields such as
__ViewState. How do you override this rendering?

Viewstate is enclosed in a DIV because that's required to produce valid
XHTML markup. inline elements (ie, input fields) must be enclosed in a
block level element in order to be valid.
 
I

intrader

http://www.aspnetpro.com/newsletterarticle/2005/11/asp200511de_l/asp200511de_l.asp

"ASP.NET 2.0 defaults to XHTML 1.1, but you can also opt for XHTML 1.0
Strict or Transitional. The rendering engine of some controls has been
reworked to make them produce compliant output. As a result, in ASP.NET 2.0,
each control's markup includes a closing tag. Furthermore, the viewstate
hidden field comes surrounded by a <div> tag and the form is only identified
by the ID attribute."

Sounds like they did this for a reason.

Greg
It seems to me that the XTHML schema allows hidden fields inside form
elements. So why do we need the div?. Check the generated (rendered)
XHTML and verify that the div is there. I have seen posts that indicate
that the div is not there, but that some controls are followed by a
carriage return. This carriage return would be ignored by any good
browser.
It will definetelly create layout problems as it is a block
element. So is this a problem with ASP.NET 2.0?
 
E

Erik Funkenbusch

On Tue, 08 Nov 2005 21:03:47 -0500, Greg Burns wrote:
It seems to me that the XTHML schema allows hidden fields inside form
elements. So why do we need the div?

No. While it's true that hidden fields have to be inside form elements to
be posted, it has nothing to do with form elements per se. The problem is
that input elements are inline elements, and inline elements must be
contained in block elements.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top