`I just spent about 3 hours trying to fix this error with the LoginStatus control. The control updates fine when I log in, but when I click the “Logout” link on the LoginStatus control I wasn’t getting a postback. After a little more looking I noticed I was getting a javascript error whenever I clicked Logout. The error I was getting was “TheForm is undefined”. I googled and googled and googled and ultimately I didn’t find the fix for my problem on google but I did find a lot of different solutions to the problem. I am consolidating them with the solution for me all in one place so that hopefully noone else has to go through this.
Scenario 1
Make sure when including external Javascript files like so:
[code lang='html']
[/code]
Scenario 2
The script created by Asp.Net references your form by id. Make sure your form id matches what is shown in the javascript generated. For instance mine had to be named Aspnetform so I made sure it looked like:
[code lang='html']
[/code]
This will not work. Swap the order of your tags to be thusly:
[code lang='html']
[/code]
Hope this helps someone else.

thank you so much.. it worked.
Comment by coldfront2006 — July 2, 2009 @ 9:26 am
Great info … On my page, the BODY and FORM tags were in the wrong order. Fixing that eliminated the error.
Comment by Ben Amada — October 20, 2009 @ 11:27 pm
cant believe it was because of the wrong closing tag! thanks!!
Comment by pablo — October 28, 2009 @ 8:34 am
Thanks a bunch.
Comment by Amar — October 29, 2009 @ 8:08 am
Thank you so much!! First scenario worked!! Saved me a lot of time. Thanks!
Comment by Jignesh — January 29, 2010 @ 1:45 pm