Form Inside of a User Control - Q817779 And Q817779

Posted on April 20, 2004  |  

Posted in Development

3 comments

Those of you who have been unfortunate to place a server-side form inside a user control probably know that the form seizes to work. Why?

I do this all the time. I'm a big believer in page templates. I think they are a must when developing for the web. Templates are a powerful vehicle for incapsulating a lot of mundane logic and providing a consistent look and feel. Both efficient and pleasing to the eye.

My templates get loaded from a "page base" class and as such they are user controls. What happens is the postback JavaScript references your form incorrectly:

...
  theform = document._ctl0:form1;
...

Any browser throws a JavaScript error. There are two Knowledge Base articles at Microsoft that talk about it:

Where there is a bug, there is a fix. Ironically, Microsoft keeps this locked behind seven doors with seven locks of Tech Support. Basically, you're left screwed if you don't have a budget or a subscription. Luckily, I found that InstantASP kindly provided it for download. Kudos to InstantASP!

Once the fix is applied, everything is back to how it's supposed to be:

  theform = document.forms["__aspnetForm"];

I've also devised a hack which is void of this problem in the first place. See Producing XHTML-Compliant Pages With Response Filters.

3 comments

Scot
on May 18, 2005

Just to let you know, the link that InstantASP has for Windows 2003 does not work. It has a file but if you try to install it, it fails...

Thanks though!


Milan Negovan
on May 18, 2005

Really, it fails? Hmm... It's been a while since I downloaded it last.


sourabh
on February 10, 2007

thank you so much for this post. i was really stuck at this error for some time. im running xp sp2 and i have applied 2000's patch. everything is working gr8. thanx 2u.


Leave a comment

  •