Use Single PopupControlExtender with multiple targets

Last post 02-20-2008 7:37 AM by Jonathan Shen – MSFT. 1 replies.

Sort Posts:

  • Use Single PopupControlExtender with multiple targets

    02-14-2008, 1:27 PM
    • Member
      18 point Member
    • thebark
    • Member since 08-18-2002, 4:36 PM
    • Tulsa, OK
    • Posts 14

    I am trying to design a page with 3 gridviews.  Each column in the gridviews is a textbox that will be populated from a DropDownList (or ListBox) from within a popupcontrolextender.  In each case the dropdownlist is populated by the same SQL stored procedure which gets passed 2 parameters... the SectionID (which gridview) and the ColumnID.  Is it possible to only create 1 popupcontrolextender with one dropdown box and re-use it for each of the textboxes?  Or will I need to create a separate popup for each textbox.

    Has anyone done anything similar to this?

     Thanks!

    Roger

  • Re: Use Single PopupControlExtender with multiple targets

    02-20-2008, 7:37 AM
    Answer

    Hi Roger,

    Here is a sample to only use one HoverMenu in a TreeView.  Although it is a little difference with your requirement, but it points out a way to achieve what you want.  You can find its public functions on PopupControlBehavior.js and PopupBehavior.js.   

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        int myIndex = 0;
        protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {   
            e.Node.Text = "<div id='myDiv" + myIndex.ToString() + "' onmouseover='showHoverMenu(\"myDiv" + (myIndex++).ToString() + "\")' onmouseout='hideHoverMenu()'>" + e.Node.Text + "</div>";
        }
    </script>.
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" DataSourceID="SiteMapDataSource1" OnTreeNodeDataBound="TreeView1_TreeNodeDataBound">
            </asp:TreeView>
            <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
             <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px" style="display:none">
                 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </asp:Panel>
            <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" BehaviorID="myHMEBID" runat="server" PopupControlID="Panel1" TargetControlID="Button1">
            </ajaxToolkit:HoverMenuExtender>
            <div style="display:none">
            <asp:Button ID="Button1" runat="server" Text="Button" /></div>
            <script language="javascript" type="text/javascript">
            var activeDivID="";
            function pageLoad(){
                $find("myHMEBID").add_shown(onHoverMenuShown);
            }
            function onHoverMenuShown(){
              var activeDivLocation = $common.getLocation($get(activeDivID));
              $common.setLocation($find("myHMEBID").get_popupElement(),new Sys.UI.Point(activeDivLocation.x + $get(activeDivID).offsetWidth,activeDivLocation.y));
              $get("<%=TextBox1.ClientID %>").value = $get(activeDivID).innerText;
            }
            function showHoverMenu(divID){
               activeDivID = divID;
               $find("myHMEBID")._onUnhover();   
               $find("myHMEBID")._onHover();
            }
            function hideHoverMenu(divID){
               $get("<%=Panel1.ClientID %>").style.display= "none";
            }
        </script>
        </div>
        </form>
    </body>
    </html>
    

    Best regards,

    Jonathan 

     

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (2 items)
Microsoft Communities