Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Saturday, November 17, 2007

'the form' is undefined - Why can't things ever be simple?

Ok. There are times when I want to go to Microsoft and their infinitly great team of extremely tech savvy and wise developers and get down on my knees and ask why they are trying to make me miserable. I could whine. I could bitch. I could complain. My guess is that no one would care. It may be that the Microsoft team isn't even the source of my problem. But we all need someone to blame so those guys & gals will do just fine.

Here is my latest little issue. I am working on a website that is going to be fantabulous (Please don't freakin' email me! I know it's not a REAL word! However, I'm a woman and I can say whatever I damn well please!). The site is called ShowOffYou and its a site for social site backgrounds, layouts and graphics. The exact address is http://www.showoffyou.com/. I'll keep you updated about it's "grand opening." Anyway let me get back to my story.

I am using master pages on this site. Code reuse - I just love it. Everything was going along smoothly and I was in a great mood. I created a .js file to hold all of my wonderful javascript functions and I added this file to my master page. I added it to my master page's head section using the following notation:



Everything was going along well until I tested my document. All of a sudden, I start getting these wonderful javascript errors. Now I could leave them, but I hate to give regular people out there a reason to think that I'm less than perfect :-). Here is the error.



Just in case you are lazy or just don't feel like clicking on the image above, I will tell you what it says. It says 'the form' sys is undefined. 'the form' is undefined??? Oh come on! :-(

Ok. I looked at the source code via the browser. It seemed fine. I looked at my web.config file. It looked just great. Ok. So what now??????
WELL, it appears that .Net does not like the way I did a particular thing. That THING is that I didn't use the end script tag. I CANNOT BELIEVE IT!!! This javascript error was caused because I didn't use an end script tag! What? Ok. What-Ev-Ver (Please don't email me to correct me. I know that whatever is not spelled What-Ev-Ver - but again, I can say What-Ev-Ver I want How-Ev-Ver I want.)


Here is the correct way the script should have been written.






That's it! If you get that dreaded 'theform' is undefined error, just make sure that your script tag has an end script. There may be additional reasons for this 'theform' is undefined error, however, this is a simple fix to look at first.

I hope someone benefits from my 'theform' is undefined ramblings.
Have lots of dotnet fun people!!




Smooches,

Kila

Summary

Error: Javascript error displayed to end users in their browser - 'theform' is undefined

Cause: Defining the script tag without an ending script tag in the head section of your asp.net document.

Fix: Change the way you define the script tag. Make sure that there is a beginning tag and a full end tag. See the images above.

Comments anyone?