How can I prevent a textbox from taking focus on the postback when I have a calendar extender on it?
- by Biff MaGriff
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 and it looks really.... dumb.
How can I stop this?