Dynamic use of HoverMenuExtender RRS feed

  • Question

  • User-1880235900 posted

    From a database I get some text. In that text there can be one or more words where I would like to use HoverMenuExtender. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Lets say that my text is: "Here is a #word# and another #word#. And the text continues ..."<o:p></o:p>

    <o:p> </o:p>

    The #...# shows where HoverMemuExtender is to be placed. When I put the mouse over the words above a panel with the text "Hello <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:address w:st="on"><st1:Street w:st="on">box</st1:Street> 1</st1:address>", "Hello box 2", ... appears.<o:p></o:p>

    <o:p> </o:p>

    The text placed on my webpage changes. Therefore I have to add the Hovermenuextender when the program is run.<o:p></o:p>

    <o:p> </o:p>

    How do I solve that problem ?<o:p></o:p>

    Thursday, May 18, 2006 9:40 AM

All replies

  • User88775175 posted

    You need to dynamically add the controls and to the page during the Page_Load event. The alternative is to dynamically generate the ASPX page with markup for the text and force the user to navigate to that page. But that'll be expensive the first time because the page needs to be compiled.

    If you are using UpdatePanel's ... it's even tricker as you'll need to create multiple HoverMenuExtenders per panel.

    Lots of threads on this topic of dynamically adding extenders and setting their properties.



    Thursday, May 18, 2006 4:30 PM
  • User-1880235900 posted

    I have read the threads but It did not help me that much. That is why I wrote my question.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    As you write I the idea is to generate the hovers in the Page_load. But I have some difficulties creating the code.<o:p></o:p>

    I have tried to make a little example activated with at button. But even this simple example does not work. The error message is "Control 'lnk1' of type 'LinkButton' must be placed inside a form tag with runat=server. "<o:p></o:p>

    My code is:<o:p></o:p>

      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim lnk As New LinkButton
        Dim ext1 As New HoverMenuExtender
        Dim prop1 As New HoverMenuProperties
        Dim panel2 As New Panel
        panel2.ID = "Panel2"
        panel2.Controls.Add(New LiteralControl("<br>Here is some  "))
        lnk.ID = "lnk1"
        lnk.Text = "Text"
        ext1.ID = "ext1"
        prop1.TargetControlID = "lnk1"
        prop1.PopupControlID = "Panel2"
        Page.Controls.Add(New LiteralControl("<br>Here is some  "))
        Page.Controls.Add(New LiteralControl(" with a hover."))
      End Sub

    What have I misunderstood?<o:p></o:p>

    I would be very very happy is someone has some time to make a coded example that solves the question in my first message.

    Saturday, May 20, 2006 3:53 AM
  • User1240420369 posted
    The Control "lnk1" has to be inside a panel or div or something. Try using panel1.Controls.Add(lnk) instead of the Page.Controls.Add(lnk) and It should compile.
    Saturday, June 3, 2006 8:20 PM