views:

22

answers:

0

Hello,

I have repeater, inside this repeater is a user control. In my c# codebehind on my user control I dynamically add a textbox and assign a calendar extender to it. Similar to this.

//custom control
protected void Page_Load(object o, EventArgs e)
{
    TextBox tb = new TextBox();
    tb.ID = "myTextBox";
    MaskedEditExtender meeDate = new MaskedEditExtender();
    meeDate.ID = "meeDate";
    meeDate.TargetControlID = this.UniqueID + "$" + tb.ID;
    meeDate.Mask = "99/99/9999";
    meeDate.MaskType = MaskedEditType.Date;
    CalendarExtender ce = new CalendarExtender();
    ce.ID = "ceCalendar";
    ce.TargetControlID = this.UniqueID + "$" + tb.ID;
    this.Controls.Add(tbDate);
    this.Controls.Add(meeDate);
    this.Controls.Add(ce);
}

This works well, however after I postback the textbox takes focus and the calendar extender fires, this causes the calendar to be displayed and it blocks other controls.

How can I stop this?

Edit: Changed wording of problem