Search This Blog

Saturday, June 9, 2012

How to display a button on rightclick in a listbox?

Use the bellow code to display a Context Menu on right click..
Here a button is as context menu.
Javascript:

<script type="text/javascript">
    function callme(x) {
       var MainContent_btnX = document.getElementById("MainContent_btnX");
       MainContent_btnX.style.display = 'block';
       //alert(x);
    }

</script>

ASP.Net
<asp:Button ID="btnX" runat="server" OnClick="btnX_Click" Text="Test Transaction" style="position:absolute;z-index:999;display:none" />
<asp:ListBox ID="lstBox" runat="server" oncontextmenu="callme('1');">
    <asp:ListItem Text="Good">1</asp:ListItem>
    <asp:ListItem Text="Morning"> 2</asp:ListItem>
</asp:ListBox>

No comments:

Post a Comment