Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement right-clicking context menu using PopupControlExtender?

Is it possible to implement a context menu which appears when users perform a right-click on an item of interest using the PopupControlExtender?

From investigations so far, it seems like the PopupControlExtender only works with left-clicks or the other choices are to write your own control or implement the entire solution in jQuery.

If it is possible to do a right-click with the PopupControlExtender, may I get some code examples?

like image 244
methon.dagger Avatar asked Mar 28 '26 15:03

methon.dagger


1 Answers

Just have a hidden button on the form for the PopupControlExtender, then capture the right click and call document.getElementById('bla').click();

JS:

$('#element').mousedown(function(event) {
    switch (event.which) {
        case 1:
            //alert('Left mouse button pressed');
            break;
        case 2:
            //alert('Middle mouse button pressed');
            break;
        case 3:
            document.getElementById('bla').click();  
            break;
        default:
            //alert('You have a strange mouse');
    }
});

Markup:

<asp:button id="bla" runat="sever" style="display:none"/>
.....PopupControlExtender code...etc
like image 58
rick schott Avatar answered Mar 31 '26 06:03

rick schott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!