views:

77

answers:

1

I think I might know the cause, but not how to fix it without a lot of code rewriting(which I prefer to avoid).

I have

public class datecontrol : basecontrol
{
    private ImageButton _ImageButton;
    private TextBox _EditControl;
private CalendarExtender _CalendarExtender;
....
    public datecontrol{
      _ImageButton=new ImageButton();
      _EditControl=new TextBox();
      _CalendarExtender=new CalendarExtender();
      .....
      _CalendarExtender.TargetControlID=_EditControl.ID;
    }
}

and

public class basecontrol : Panel,INamingContainer
....

Now here is the strange part. _CalendarExtender gives errors on finding the ID for _EditControl as the TargetID. It sounded like a naming container problem, so I looked and looked and could not find anything. Then I looked with the debugger. _EditControl and _ImageButton both have their naming container set to this as expected, but _CalendarExtender has it's naming container set to null.

I would love to try to fix this problem myself with _CalendarExtender.NamingContainer=this; but that is a read-only property.

The only reason I can figure out this could be happening is because _CalendarExtender inherits from ExtenderControl->Control. Where a Panel inherits from WebControl->Control.

Does anyone know something I could be missing or a workaround for this problem or something?

A: 

Ok, I was adding the calendar extender(later in code) to a different panel than the one containing the edit control, which I assume is why I got such an error..

Earlz