This is a migrated thread and some comments may be shown as answers.

SplitButton Double Click

1 Answer 93 Views
Button
This is a migrated thread and some comments may be shown as answers.
Ryan Grossman
Top achievements
Rank 1
Ryan Grossman asked on 03 May 2015, 03:08 PM

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>

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 05 May 2015, 11:47 AM
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.

 
Tags
Button
Asked by
Ryan Grossman
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or