T
Thomas Due
Hello,
I am in the process of making my asp.net form to validate as xhtml 1.0
strict. So far I am doing well, but now I have a problem. The problem
concerns specifically DropDownList and ListBox, but other controls
might result in the same problem.
When AutoPostBack is enabled on these controls, two hidden input fields
are created on the form (__EVENTTARGET and __EVENTARGUMENT),
furthermore a "postback" javascript is embedded, this javascript looks
something like this:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["MainForm"];
}
else {
theform = document.MainForm;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
My problem is that after I converted my forms to xhtml, this javascript
ceased to work. The error Im getting is: "__EVENTTARGET is null or not
an object". I suspect it has something to do with the fact that the
javascript does not conform to the proper syntax and grammar for
javascript in xhtml. As far as I have learned the proper way to access
a control is by using "document.getElementById" and not call it
directly. I can easily change the script to conform, but how do I
replace the one mentioned above?
So, my problem is: How do I retain the autopostback functionality on
e.g. DropDownList but prevents it from registering the javascript?
I am in the process of making my asp.net form to validate as xhtml 1.0
strict. So far I am doing well, but now I have a problem. The problem
concerns specifically DropDownList and ListBox, but other controls
might result in the same problem.
When AutoPostBack is enabled on these controls, two hidden input fields
are created on the form (__EVENTTARGET and __EVENTARGUMENT),
furthermore a "postback" javascript is embedded, this javascript looks
something like this:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["MainForm"];
}
else {
theform = document.MainForm;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
My problem is that after I converted my forms to xhtml, this javascript
ceased to work. The error Im getting is: "__EVENTTARGET is null or not
an object". I suspect it has something to do with the fact that the
javascript does not conform to the proper syntax and grammar for
javascript in xhtml. As far as I have learned the proper way to access
a control is by using "document.getElementById" and not call it
directly. I can easily change the script to conform, but how do I
replace the one mentioned above?
So, my problem is: How do I retain the autopostback functionality on
e.g. DropDownList but prevents it from registering the javascript?