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 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!!




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 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?


Anonymous said...

Thanks it was very helpful.

Mattster said...

Just got this problem, and your fix worked perfectly (VS2008). What an annoyance!

Many thanks for this tip, you've undoubtedly saved me countless hours of banging my head against the monitor. :-)


Kila Morton said...

I'm so glad that you were able to find this information useful! Don't you just hate the little bugs?

Deji said...

Thanks. It worked. I had this issue for 3 hours last nite and couldnt figure it out until i found your solution just this morning.

Ken Sykora said...

That's actually not a .NET issue, it's an HTML issue. Browsers in general will not respect script blocks that are self closing and reference an external file. Try it on a static HTML page, you'll get errors running your external script.

Kila Morton said...

Hi Everyone,

I'm glad you found this helpful!

Ken: Ken, Ken, Ken! First, thanks for stopping by. Second, you will notice that I never identified this error as a .net error. I identified It is a javascript error. Javascript errors happen across all web languages. I'm not beating up on you. I'm just saying what I said. :-)

glen said...

that's for your post, i was stumped on that one, rather pissy - ok very pissy, and am amazed in the worst possible way that the fix was what it was. double you, tea, eph, exclamation...
thanks again, if it wasn't for your post i'd have lost moor than just two hours to this ridiculousness.

Kila Morton said...

Glen I'm so glad that this was able to help you save time. It's those pesky little things that keep us programmers up at night wondering...

Joel said...

Just ran into this same issue. You're a lifesaver! I thought I was going insane. Turns out it's just Microsoft being insane. Pleasant change.

Scottaculous said...

Thank you! I can't believe that was the answer.

Kila Morton said...

@Scottaculous - I know! Doesn't it seem like there should be more to it than that? LOL!

nerd. said...

Thanks, saved me a bit of heartache on that too!! Have some smooches back :)

Kila Morton said...

@nerd AWESOME! Make smooches your new catch word!

nettyfish said...

Your Blog post has very helpful information.
Thanks for share....

Bulk SMS Services Provider in Chennai

raybanoutlet001 said...

michael kors outlet online
ugg boots
ray ban sunglasses outlet
michael kors outlet
green bay packers jerseys
michael kors handbags
mont blanc outlet
boston celtics jersey
jordan shoes
snapbacks wholesale

raybanoutlet001 said...

raiders jerseys
bills jerseys
cheap ray bans
jets jersey
nike soccer shoes
bengals jersey
gucci outlet
true religion outlet store
coach factory outlet
christian louboutin outlet