ASP.NET DataGrid and HoverMenu Extender

I have an ASP.NET DataGrid that I am trying to add to the HoverMenu Extender. The grid layout looks like this:

<asp:datagrid id="dgrExisting" runat="server" autogeneratecolumns="false" cssclass="FormattedTable" onitemcommand="dgrExisting_ItemCommand" onitemdatabound="dgrExisting_ItemDataBound">
                <headerstyle cssclass="FormattedTableHeader">
                <alternatingitemstyle cssclass="FormattedTableAltRow"></alternatingitemstyle>
                <columns>
                    <asp:boundcolumn datafield="UrlId" visible="false"></asp:boundcolumn>
                    <asp:boundcolumn datafield="MonitorUrl" headertext="Url"></asp:boundcolumn>
                    <asp:boundcolumn datafield="LastChecked" headertext="Last Checked"></asp:boundcolumn>
                    <asp:boundcolumn datafield="NextCheck" headertext="Next Check" visible="false"></asp:boundcolumn>
                    <asp:boundcolumn datafield="LastLoadTime" headertext="Last Load Time&lt;br&gt;&lt;/asp&gt;(Milliseconds)">
                    <asp:boundcolumn datafield="LastStatus" headertext="Last Status"></asp:boundcolumn>
                    <asp:templatecolumn>
                        <itemtemplate>
                            <asp:panel id="pnlPopupMenu" runat="server">
                                <div style="border: 1px outset white; padding: 2px;">
                                    <div><asp:linkbutton id="lnkReport" runat="server" commandname="Report" text="View Reports"></asp:linkbutton></div>
                                    <div><asp:linkbutton id="lnkDelete" runat="server" commandname="Delete" text="Delete"></asp:linkbutton></div>
                                    <asp:confirmbuttonextender id="cbeNewDelete" runat="server" targetcontrolid="lnkDelete" confirmtext="Are you sure you want to remove this URL?"></asp:confirmbuttonextender>
                                </div>
                            </asp:panel>
                            <asp:hovermenuextender id="hoverMenu" runat="server" popupcontrolid="pnlPopupMenu" popupposition="Right" hovercssclass="popupHover" targetcontrolid="pnlPopupMenu" popdelay="50"></asp:hovermenuextender>
                        </itemtemplate>
                    </asp:templatecolumn>
                </asp:boundcolumn>
            </columns>
</asp:datagrid>

      

In the ItemDataBound event I set the ID so that it works for the whole row, for that I use the following:

protected void dgrExisting_ItemDataBound(object sender, DataGridItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        AjaxControlToolkit.HoverMenuExtender oHoverMenu = (AjaxControlToolkit.HoverMenuExtender)e.Item.FindControl("hoverMenu");
        e.Item.ID = e.Item.ItemIndex.ToString();
        oHoverMenu.TargetControlID = e.Item.ID;
    }
}

      

However, the menu is displayed, but clicking on the link buttons never sends messages back to the server, allowing the item's command to be processed. If I turn off the hover menu extender, the buttons work as expected.

What am I missing?

+1


a source to share


1 answer


Instead of trying to implement the behavior in the code behind, I nested links ...

<itemtemplate>
    <asp:label id="lblOptions" runat="server">Options</asp:label><img src="../Images/RightArrow.png" alt="Show Menu" />

    <asp:panel id="pnlMenu" runat="server" cssclass="popupMenu">
        <div class="popupItem"><a href="Uploader.aspx?Action=Copy&Id=<%#Eval("Id")%>">Copy</a></div>
        <div class="popupItem"><a href="Uploader.aspx?Action=Version&Id=<%#Eval("VersionId")%>">Upload New Version</a></div>
        <div class="popupItem"><a href="VersionBrowser.aspx?id=<%#Eval("Id")%>">View Versions</a></div>
    </asp:panel>

    <cc1:hovermenuextender id="hme" runat="server"
         hovercssclass="popupHover"
         popupcontrolid="pnlMenu"
         targetcontrolid="lblOptions"/>
</itemtemplate>

      



+1


a source







All Articles