HTML 4.01 and the PostBack javascript

S

Svein Terje Gaup

When I try to validate my webpages on http://validator.w3.org the validation
fails because of the auto-generated postback function:

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.defaultframework_Default;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

The reason for failing is that the script tag is missing the TYPE attribute.
Th script tag should be like this to be valid HTML 4.01:
<script language="javascript" type="text/Jscript">

Is there any way, any options or method for altering this SCRIPT tag?

I probably should say that I'm using .NET Framework 1.0.

Regards
Svein terje Gaup
 
M

Michael

Well I can't say for sure, but I doubt there is an "easy" way to change
this. What you can do is override the render event for the page, and do a
find/replace to alter the javascript before it is sent to the client.

It would be something like this in your codebehind, which inherits from
System.Web.UI.Page.

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
Dim sw As New System.IO.StringWriter
Dim localWriter As New HtmlTextWriter(sw)

MyBase.Render(localWriter)
Dim output As String = sw.ToString()

'here is where you would have to do a find/replace on the string to
edit the javascript tag
'but as an example I'll change everything to uppercase.
output = output.ToUpper()

writer.Write(output)

End Sub

--Michael
 

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

Top