I have a WebDropDown with a footer template that has an image control in with an id of "addimage". I want to tie an event handler to the click event of the image button, how do I do this? I cannot access a control named "addimage" in my codebehind and adding an attribute of "OnClick" to the aspx does not work either. If it makes a difference, my webdropdown is located in a usercontrol.
Thank you
Hi,
Here is an example, I hope it works for you:
ASPX:
<form id="form1" runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<div>
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" DropDownContainerHeight="200px" EnableClosingDropDownOnBlur="false" EnableClosingDropDownOnSelect="false">
<Items>
<ig:DropDownItem Text="Item 1" Value="1"></ig:DropDownItem>
<ig:DropDownItem Text="Item 2" Value="2"></ig:DropDownItem>
<ig:DropDownItem Text="Item 3" Value="3"></ig:DropDownItem>
</Items>
<FooterTemplate>
<asp:ImageButton runat="server" ID="addimage" ImageUrl="<URL TO SOME IMAGE>" OnClick="addimage_click"/>
</FooterTemplate>
</ig:WebDropDown>
</div>
</form>
Code behind:
protected void addimage_click(object sender, ImageClickEventArgs e)
{
WebDropDown1.Items.Add(new Infragistics.Web.UI.ListControls.DropDownItem("new item"));
}
By the way, you are right that it should be possible to edit the footer/header template contents directly at DesignTime in Visual Studio, there you would be also able to add all handlers declaratively in the design time. Currently it is possible to only edit the ItemTemplate in the design time, there is a known issue that currently footer and header templates cannot be seen at design time, which is already fixed and will be available in a future hotfix.
Thanks,
Angel
If I put my WebDropDown directly on a page this works fine. If I put my WebDropDown in a UserControl or an Infragistics WebTab (the two options I have tried) it does not work. A post back does occur but the OnClick routine does not get fired.