Skip navigation.

Visual SourceSafe Daily AggravationAll recent postsForgent Networks Enters Pissing Contest Over JPEG

Form Inside of a User Control - Q817779 And Q817779

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.

Comments

Comment permalink 1 Scot |
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!
Comment permalink 2 Milan Negovan |
Really, it fails? Hmm... It's been a while since I downloaded it last.
Comment permalink 3 sourabh |
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.

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):