Closing the DropDownExtender's Panel manually

Discussion in 'ASP .Net' started by Abbas, Jul 26, 2007.

  1. Abbas

    Abbas Guest

    Hi,

    I have a nested DIV structure where both have an onclick event, hence
    I am cancelling the event from bubbling up to the outer DIV, but this
    has caused the Panel to remain opened when I click on another dropdown
    (in another item within my repeater) or anywhere else on the page, and
    I am wondering if anyone knows how to close the panel manually using
    the AjaxControlToolkit.DropDownBehavior?

    Here is some source code:

    <asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
    <%# Eval("Text") %>
    <div id="test<%=counter++ %>" onclick="cancelEvent(event)";>
    <asp:Label ID="TextLabel" runat="server" Text="Select your
    favorite exotic ice-cream flavor"
    Style="display: block; width: 300px; padding:2px; padding-
    right: 50px; font-family: Tahoma; font-size: 11px;" />
    <asp:panel ID="DropPanel" runat="server"
    CssClass="ContextMenuPanel" Style="display :none; visibility:
    hidden;">
    <asp:LinkButton CommandArgument="www.google.ca"
    runat="server" ID="Option1" Text="Mocha Blast"
    CssClass="ContextMenuItem" OnClick="OnSelect"/>
    <asp:LinkButton CommandArgument="www.google.ca"
    runat="server" ID="Option2" Text="Java Cyclone"
    CssClass="ContextMenuItem" OnClick="OnSelect" />
    <asp:LinkButton CommandArgument="http://www.google.ca"
    runat="server" ID="Option3" Text="Dry Fruit"
    CssClass="ContextMenuItem" OnClick="OnSelect" />
    <asp:HyperLink ID="HyperLink1" runat="server"
    Text="HyperLink" NavigateUrl="http://www.google.ca"
    CssClass="ContextMenuItem" />
    </asp:panel>
    <ajaxToolkit:DropDownExtender runat="server" ID="DDE"
    TargetControlID="TextLabel"
    DropDownControlID="DropPanel" /></div>
    <br />
    <asp:UpdatePanel id="Update" runat="server">
    <ContentTemplate>
    <asp:Label id="lblSelection" runat="server"
    Style="padding: 5px;" />
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Option1"
    EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="Option2"
    EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="Option3"
    EventName="Click" />
    </Triggers>
    </asp:UpdatePanel>
    </ItemTemplate>
    </Repeater>


    The JavaScript:

    function cancelEvent(e) {
    //var test =
    AjaxControlToolkit.DropDownBehavior.get_isOpen();

    //src.onclick();
    alert('cancel');
    if(window.event) {
    alert('1');
    if (!e) e = window.event;
    e.cancelBubble = true;
    }
    else if ( e.stopPropagation) {
    // alert('2');
    e.stopPropagation();
    }
    else {
    alert('3');
    return false;
    }
    }
     
    Abbas, Jul 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    7
    Views:
    387
    darrel
    Oct 15, 2004
  2. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    657
    Thomas Hansen
    Feb 15, 2007
  3. Jacol
    Replies:
    2
    Views:
    362
    Jacol
    Feb 19, 2007
  4. tirath
    Replies:
    0
    Views:
    1,619
    tirath
    Apr 5, 2007
  5. thomas
    Replies:
    0
    Views:
    230
    thomas
    Oct 23, 2003
Loading...

Share This Page