Thursday, June 26, 2008

The script tag requires a closing tag in XHTML

Platform: ASP.NET

If you don't close the script tag in head or body of an ASPX file, then you will get a strange error: __doPostBack is not defined

Problem: Any script (and style) tags need a closing tag. Don't close these tag like:

<type="text/javascript" src="somefile.js" />

Solution: The script tag either in the head or the body of an XHTML file has to have a closing tag. Correct this javascript error by doing this:

<type="text/javascript" src="somefile.js"></script>

Possible reason: This has to do with the content of the script tag being defined as #PCDATA in its DTD.

0 comments: