Tags

,

Today, I spent time on using AJAX HoverMenuExtender to display details for  Listview items.

I got problem when declare HoverMenu at design time, so I created them on Databound event.

So on the html page

<ItemTemplate>

<asp:HyperLink ID=”lblTitle” runat=”server”/>
                                                <asp:Panel CssClass=”detailsPanel” ID=”PopupPanel” runat=”server” style=”display:none;”>
                                                    <asp:Label ID=”lblHighlight” runat=”server” Text=”Label”></asp:Label>
                                                </asp:Panel>

</ItemTemplate>

So on the code behind databound method:

                HoverMenuExtender titleHme = new HoverMenuExtender();
                HyperLink titleLnk = e.Item.FindControl(“lblTitle”) as HyperLink;
                Label hightlightLabel = e.Item.FindControl(“lblHighlight”) as Label;

                    titleHme.PopupControlID = PopupPanel.ID;
                    titleHme.TargetControlID = titleLnk.ID;
                    titleHme.PopupPosition = HoverMenuPopupPosition.Right;
                    titleHme.ID = “hmeTitle”;
                    titleHme.OffsetX = 5;
                    e.Item.Controls.Add(titleHme);

Be careful Literal control cannot be used as Target control

Advertisements