Ever had the following problem: 'theForm.__EVENTTARGET' is null or not an object?
I will reproduce this problem in this site and suggest a possible solution for this problem.
I came across this when converting a ASP.Net 1.1 website to .Net 3.5. It has to do with a change made to optimize the javascript code
generated by .Net concerning the postback. In 1.1. the code is executed every time, but in 2.0 some
initialization is done at document load time.
.Net 1.1 style:
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
theform = document.form1;
}
else {
theform = document.forms["form1"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
.Net 2.0 style
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
It occurs when you have javascript on the page that changes the HTML DOM in a particular way
(using: document.body.innerHTML = ...).
You should change your javascript, or if you really need it, use this solution.
Look at my javascript file to identify the problem and to see a part of the solution.
Ok, let's go and reproduce the problem.
Check the checkbox and click Submit to enable the fix.