SplitButton Double Click

2 posts, 0 answers
  1. Ryan Grossman
    Ryan Grossman avatar
    12 posts
    Member since:
    Nov 2009

    Posted 03 May 2015 Link to this post

    If I have a splitbutton and open the content menu first by clicking on the arrow and then click on the main button it doesnt execute the onclick event. I have to click it again in order to execute. Can the button be setup so that the main button always clicks the first time you click it regardless of if the context menu of the button is expanded first?

     

    <telerik:RadButton EnableSplitButton="true" ID="btnSave" runat="server" Text="Save Contact" OnClick="RadButton1_Click" OnClientClicked="OnClientClicked">
                    </telerik:RadButton>
                    <telerik:RadContextMenu ID="rmContextMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" style="z-index: 1009" CollapseAnimation-Type="None" ExpandAnimation-Type="None">
                        <Items>
                            <telerik:RadMenuItem Text="Save & Create New" Value="0">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Run Spell Checker" Value="1">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Cancel & Close" Value="2">
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadContextMenu>

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 05 May 2015 Link to this post

    Hello Ryan,

    I can suggest that you use the logic below to cancel the postback when the split button is clicked and execute postback when the button itself is clicked:

    ASPX:
    <script>
        function OnClientClicking(sender, args) {
            if (args.IsSplitButtonClick()) {
                args.set_cancel(true);
                alert('split button is clicked; no postback');
            }
            else {
                alert('button is clicked; postback will be performed');
            }
        }
    </script>
    <asp:Label ID="Label1" Text="" runat="server" />
    <telerik:RadButton EnableSplitButton="true" ID="btnSave" runat="server" Text="Save Contact" OnClick="RadButton1_Click" OnClientClicking="OnClientClicking">
    </telerik:RadButton>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToString();
    }

    The above code works properly on my side. You can modify it according to your scenario (e.g., show the context menu when the split part is clicked).

    Regards,
    Danail Vasilev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top