Sunday, October 4, 2009

this._form is null or not an object, JavaScript Error

I was getting below javascript error everytime i run my visual studio asp.net web pages:
this._form is null or not an object

Because of this error all my AJAX controls and page postback stopped working.

As the error clearly states that it is a JavaScript error so i started checking all my Javascript code.

Finally searching on the internet i found the cause and cure of this problem.

Cause:

If you are including javascript files in the page herader like the below:
<script src="aj.js" type="text/javascript" />

Solution:

Here the closing of script tag is not correct, through its an empty tag but somehow it needs to be closed as a old fashioned way, like done below:
<script src="aj.js" type="text/javascript"></script>

Close the javascript tag properly and see the magic yourself.