in Uncategorized

ParseChildren(true, “Content”) Fails When Child is a Form Element?

I’ve looked around and haven’t seen this described anywhere. It’s a tough bug to come up with a succint search query for though, so maybe I just missed someone else reporting it. In any case here are the details in case anyone else ever runs into this.

Basically, if you create a UserControl, decorate it’s code-behind class with [ParseChildren(true, “Content”)] where “Content” is a property of the control of type ControlCollection that redirects the controls to a region within the UserControl (say a PlaceHolder), then use this control inside of your WebForm and define an <input> as a child element it will blow up with a Parser Error of “Object reference not set to an instance of an object”. If instead you nest the form element inside of a non-form element, such as a <div> it all works. So there’s definitely something funky with the UserControlControlBuilder implementation.

It will fail with any type of form element: <input> <select> or <textarea>. The work around for today is to be explicit instead of counting on the ControlBuilder to correctly interpret the ParseChildrenAttribute. Here’s the code to repro. If anyone can tell me what I’m missing or confirm this is a bug that would be great.

Leave a comment

Comment