Question

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?

Was it helpful?

Solution

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..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top