Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Respond to Event of Control in FooterTemplate
posted

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 

TestSite.zip
Parents
No Data
Reply
  • 24671
    posted

    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 

Children