He can't try that, Alexei, because the code is being injected by ASP.NET.
He can't change the embedded javascript funtions, if he's using ASP.NET 2.0.
There's a chance he mioght be able to do that, if he's using ASP.NET 1.1.
All he'd have to do is edit the scripts located in
\wwwroot\aspnet_client\system_web\1_1_4322.
The problem doesn't seem to be that the function is buggy, though.
If Nathan were to rename the page's form to "form2",
instead of naming it "form1", he should see this :
<script type="text/javascript">
<!--
var theForm = document.forms['form2'];
if (!theForm) {
theForm = document.form2;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
Notice that the source reveals that the script has picked up the form's new name.
If that doesn't show up, and the error persists, it's a timing problem.
The javascript is running before the form has been rendered.
Juan T. Llibre, asp.net MVP
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
======================================
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
On Jun 11, 2:24 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I have an ASP.NET application which is giving the following JavaScript
error:
'theForm' is undefined
However, when I did a View Source I noticed that ASP.NET added the following
code:
<script type="text/javascript">
<!--
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();
}}
// -->
</script>
I was told in a previous posting that the reason for the error is that the
script containing the declaration and assigning of a value to it occur
before the
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
try
var theForm = document.getElementById("form1");