dynamically add a hovermenuextender to a page RRS feed

  • Question

  • User-210971832 posted


    How would i dynamically add a hovermenuextender to a page? I've been trying to do it like so but to no avail:

    Dim p As New Panel
    'add some controls to the panel

    dim hyp as new hyperlink
    'set link properties

    Dim hme As New HoverMenuExtender
    hme.TargetControlID = hyp.ID
    hme.PopupControlID = p.ID
    hme.HoverCssClass =
    hme.PopupPosition = HoverMenuPopupPosition.Right

    tc.Controls.Add(hme) 'tc is a table cell

    Nothing happens when i hover over the hyperlink and there is nothing in the html to suggess the hover menu extender is being created at all. When i create a static menu extender there is some javascript in the html that looks like it is setting up the extender.

    what am i doing wrong?

    many thanks


    Thursday, December 14, 2006 9:52 PM

All replies

  • User-1429816726 posted

    The following works for me and might help:

    <%@ Page Language="VB" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim p As New Panel
            p.ID = "p"
            p.BackColor = Drawing.Color.Aqua
            Dim l As New Label
            l.Text = "text"
            Dim h As New HyperLink
            h.ID = "h"
            h.Text = "link"
            h.NavigateUrl = "http://asp.net/"
            Dim m As New HoverMenuExtender
            m.TargetControlID = h.ID
            m.PopupControlID = p.ID
            m.PopupPosition = HoverMenuPopupPosition.Bottom
        End Sub
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Sample Page</title>
        <form id="form1" runat="server">
                <asp:ScriptManager ID="ScriptManager1" runat="server" />
    Thursday, December 21, 2006 4:43 PM
  • User-210971832 posted
    thanks a lot david, will give it a go
    Sunday, December 24, 2006 7:30 PM