How To Create Contextmenu in asp.net using Javascript (Only for IE)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContextMenu.aspx.cs" Inherits="ContextMenu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>

  <script type="text/javascript">

function contextMenuClick()
{
var objContextMenu=document.getElementById("contextMenu");


objContextMenu.style.left=event.clientX;
objContextMenu.style.top=event.clientY;
objContextMenu.style.visibility="visible";
}
  </script>

</head>
<body oncontextmenu="contextMenuClick(); return false;">
  <form id="form1" runat="server">
      <div>
          Click Here
      </div>
      <div id="contextMenu" style="position: absolute; z-index: 999; visibility: hidden;
          border: 3px solid #000080; background-color: #red; color: #ee00ee">
          <a href="AllColors.aspx">My excellent context menu</a><br />
          <a href="ajax.htm">Ajax</a>
      </div>
  </form>
</body>
</html>

No comments:

Post a Comment