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?

David Basarab
  • 72,212
  • 42
  • 129
  • 156
Earlz
  • 62,085
  • 98
  • 303
  • 499
  • Strange.. I can't seem to reproduce the error.. but if I take a stripped down version of my classes, then the naming container is still never set on the calendar.. but it doesn't throw an error about duplicate IDs or missing IDs so I'm really confused. – Earlz Sep 15 '09 at 01:29

1 Answers1

0

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
  • 62,085
  • 98
  • 303
  • 499