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
OK - found the difference. In my usercontrol I am databinding to an ObjectDatasource. Once I do that the OnClick does not fire. I added databinding to my test WebDropDown that was placed directly on a page (as opposed to a usercontrol) with the same results, a post back occurs but the OnClick event does not get fired.
Hi,
i have created a blank UserControl , and put the above code in it (as well as the code behind for addimage_click, in the WebUserControl.ascx.cs ) , and i can see that OnClick is firing. In the ASPX , i am using the user control like that :
<%@ Register TagName="test" TagPrefix="ig" Src="~/WebUserControl.ascx" %>
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.
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