I'm currently trying to add a FilteredTextBoxExtender in a ASP.NET composite control, but I can't get it to work.
I have the following code within the overridden CreateChildControls method:
var textbox = new TextBox { ID = string.Format("{0}_textbox", ID);
var filteredTextBoxExtender = new FilteredTextBoxExtender { ID = string.Format("{0}_filter", ID), TargetControlID = textbox.ID, FilterType = FilterTypes.Numbers };
Controls.Add(textbox);
Controls.Add(filteredTextBoxExtender);
Somehow, it looks like it is added correctly when I view the source of my test page, but it won't fire the filtering
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.FilteredTextBoxBehavior, {"FilterType":2,"id":"ctl00_testTextBox_testTextBox_filter"}, null, null, $get("ctl00_testTextBox_testTextBox_textBox"));
});
...
<input id="ctl00_testTextBox" name="ctl00$testTextBox$testTextBox_textBox" type="text" value="" id="ctl00_testTextBox_testTextBox_textBox" />
Any idea what goes on here, and how to get it to fire the filtering?
edit: I've narrowed it down to a matter of dynamically choosing which controls to render. The FilteredTextBoxExtender works if I explicitely render each child control, but not if I don't render one of the child controls in the composite control (a label control)