I've created a Footer UserControl that I dynamically add controls into based on a number of factors. I want some of those controls to be triggers for an UpdatePanel on the same page.
I have the following in code behind:
private void SetupFooter()
{
WebToolBar footerToolBar = this.ShowFooterToolBar("~/ToolBars/PM_Footer.ascx");
footerToolBar.ID = "PM_Footer";
footerToolBar.OnNotify += new WebToolBar.OnNotifyHandler(footerToolBar_OnNotify);
WebToolButton button = new WebToolButton();
button.ID = "btn_Add";
button.Text = "Add";
button.ImageDefault = "~/Images/Icons/16/Plus.png";
button.CommandName = "Add";
button.Group = "1";
footerToolBar.AddWebToolButton(button);
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = button.ID;
trigger.EventName = "Click";
pnl_Suppliers.Triggers.Add(trigger);
}
I get the error:
A control with ID 'btn_Add' could not be found for the trigger in UpdatePanel 'pnl_Suppliers'.
If I add the WebToolButton (basically an ImageButton with Text that I made) directly to the page and not inside the UserControl, then it works perfectly. Unfortunately I was hoping I could get this to work within my UserControl ("PM_Footer.ascx") as it encapsulates a lot of helper functionality and event hooks.
Is this at all possible? I'm clutching at straws and have tried assigning the UniqueID and ClientID to the update panel instead, but it just appears that any control within another user control cannot be used as a trigger for the UpdatePanel... which makes sense in a way.