hovermenuextender中的下拉列表

时间:2014-01-06 09:47:01

标签: c# asp.net gridview itemtemplate

我在Gridview中的hovermenuextender中有下拉列表。以下是代码。

  <asp:TemplateField HeaderText="ASSIGN" ShowHeader="False">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" Text="Assign"></asp:LinkButton>

                                    <asp:Panel ID="popupMenu" Height="200px" Width="300px" runat="server" Style="display: none; background-color: #bddee0; margin-left: 0px; margin-top: 10px">
                                        <div style="border: 1px outset white; padding: 2px;">
                                            <div>
                                                <asp:Label ID="call_no1" runat="server" Text="Label1"></asp:Label><br />
                                                <asp:Label ID="con_dept" runat="server" Text="Assign Call To : "></asp:Label>
                                                <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br />
                                                <asp:Button ID="Button3" runat="server" Text="Assign" CausesValidation="false" CommandName="assign" />
                                            </div>
                                        </div>
                                    </asp:Panel>
                                    <cc11:HoverMenuExtender ID="HoverMenuExtender1" runat="Server"
                                        TargetControlID="LinkButton1"
                                        PopupControlID="popupMenu"
                                        PopupPosition="Right"
                                        OffsetX="0"
                                        OffsetY="0"
                                        PopDelay="50" />

                                </ItemTemplate>
                            </asp:TemplateField>

我动态地绑定了下拉列表。如果下拉列表包含更多项目,则列表项目将显示在面板外。我选择其中任何一个,hovermenuextender隐藏。我想在下拉列表中选择任何项目后显示该扩展程序。 有人可以帮帮我吗?

先谢谢。

1 个答案:

答案 0 :(得分:1)

试试这个脚本

<script>
function ddlOnBlur() 
{


    var currentBehavior = null;
    var allBehaviors = Sys.Application.getComponents();
    for (var loopIndex = 0; loopIndex < allBehaviors.length; loopIndex++) 
        {
            currentBehavior = allBehaviors[loopIndex];
            if (currentBehavior.get_name() == "HoverMenuBehavior") 
               {
               // Now we get the ClientBehavior here: currentBehavior!
               currentBehavior._onHover();
               }
         }
}
</script>

<强>(OR)

<script type="text/javascript">
        function ddlOnBlur() {
            $find("HME1")._onHover();
        }
</script>

<强>(OR)

<script type="text/javascript">
        function showHoverMenu() {
            var hm = $find("HoverMenuExtender1");
            hm._popupBehavior.show();
            if ($common.getCurrentStyle(hm._popupElement, 'display') == 'none') {
                hm._popupElement.style.display = 'block';
            }
            hm._popupBehavior.set_x(hm._getLeftOffset());
            hm._popupBehavior.set_y(hm._getTopOffset());
        }
  </script>

对于此脚本,您只需将HoverMenuExtender ID设为HoverMenuExtender,而不使用behaviorID

请参阅:

http://forums.asp.net/p/1329061/2669385.aspx#2669385 http://forums.asp.net/p/1350055/2765769.aspx#2765769 http://forums.asp.net/p/1396306/3012651.aspx#3012651