Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net - how can I a function to the drop down on right click?

Posted on 2011-03-08
20
Medium Priority
?
315 Views
Last Modified: 2012-05-11
Whne I right click on my screen I need to add a function to the list so that when I click on it will execute...
0
Comment
Question by:GlobaLevel
  • 7
  • 3
  • 3
  • +4
20 Comments
 
LVL 11

Expert Comment

by:Deepak Lakkad
ID: 35078829
which type of application you are developing (Winform or Web)?

Pls. explain your requirements in detail

- Deepak Lakkad
0
 
LVL 9

Expert Comment

by:gery128
ID: 35079371
Here is Javascript snippets that will allow you to detect right click:
function doSomething(e) {
  var rightclick;
  if (!e) var e = window.event;
  if (e.which) rightclick = (e.which == 3);
  else if (e.button) rightclick = (e.button == 2);
  alert('Rightclick: ' + rightclick); // true or false
}

Open in new window

Reference link: http://www.quirksmode.org/js/events_properties.html#button
Once detected you can add JS function to your dropdown or any other controls.
-Girish
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 35079590
GlobaLevel first note that right click is interpreted in different manner in different ways thus one script may working perfectly in IE but not in Firefox or other browser so you need to checkit


 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="rightclick.aspx.vb" Inherits="rightclick" %>

<!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></title>
    <script language="javascript" type="text/javascript">
        var message = "hello";
        function click(e) {
            if (document.all) {
                if (event.button == 2) {
                    alert(message);
                    //Call Any other function
                    return false;
                }
            }
            if (document.layers) {
                if (e.which == 3) {
                    alert(message);
                    //Call Any other function
                    return false;
                }
            }
        }
        if (document.layers) {
            document.captureEvents(Event.MOUSEDOWN);
        }
        document.onmousedown = click;



       

    </script>
</head>
<body onContextMenu="alert('type message here'); ">
<%--Call Any other function in place of alert--%>
    <form id="form1" runat="server">
    <div >
    <h1>
    anurag_onnet
    </h1>
    </div>
    </form>
</body>
</html>

Open in new window



<script language="javascript" type="text/javascript">
        var message = "hello";
        function click(e) {
            if (document.all) {
                if (event.button == 2) {
                    alert(message);
                    //Call Any other function
                    return false;
                }
            }
            if (document.layers) {
                if (e.which == 3) {
                    alert(message);
                    //Call Any other function
                    return false;
                }
            }
        }
        if (document.layers) {
            document.captureEvents(Event.MOUSEDOWN);
        }
        document.onmousedown = click;
    </script>



used for IE and onContextMenu="alert('type message here'); " used for Firefox
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 10

Author Comment

by:GlobaLevel
ID: 35084099
Please see attachment for clarification...it contains a screenshot that spells it all...any questions please let me know...
Send-Highlight.docx
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35084190
so I need to add it to the menu that appears once the user right clicks...
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 35091172
ya once the user right click , first the above script should be activated and in the alert section add your menu scripts.
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35113177
well i tried to run to select  "anurag_onnet" and send to db...but wouldnt work...any ideas..?

code below...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35290066
I have no idea what you have tried, and what problems that you are having, which makes it difficult for me to help you (if I can)...
0
 
LVL 31

Expert Comment

by:MlandaT
ID: 35294883
This something you have to do by playing around with the windows shell...

[NOTE: Most of these examples deal with the explorer menus, not specifically that menu you are looking for... however, you may pick up some ideas from these.

http://www.extremetech.com/article2/0,2845,1838907,00.asp
http://www.extremetech.com/article2/0,1697,1838905,00.asp
http://www.tucows.com/article/1187
http://www.jfitz.com/tips/rclick_custom.html
http://sumtips.com/2011/02/hacks-to-enhance-windows-context-menu.html

Caution: Before editing your registry, it would be wise to create a system restore point by using system restore. Doing so will provide an easy method to revert back to your original configuration before you make any changes—just in case you accidentally delete or modify something that hurts your computer.
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35297283
TheLearnedOne...see the link in this post for attachment...

35084099
http://35084099
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35298844
I can't access that link.  What type of attachment is it?  Is it a type that you can't attach to this question?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35306583
You have selected ASP.NET as one of the zones. Do you want to add menu item to a browser's right click menu?
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35342907
You have selected ASP.NET as one of the zones. Do you want to add menu item to a browser's right click menu?

>> correct...
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35342983
I dont think you can do that from a website. This has to be done on the client computer. And it would be browser specific.
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35443132
so I made some progress...I get how to add items to the context menu via the registry...but will the registry allow me to add items such as a program.. .exe to it?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35443222
You managed to add items to a client registry from a website?
0
 
LVL 31

Expert Comment

by:MlandaT
ID: 35443346
I am not sure whether you can modify at applicaiton level. I have tried looking around, but cannot quite seem to find anything. However, the articles I have seen on this seem to point to using a global system hook to capture the WM_CONTEXTMENU message. Hoewever, note that Global hooks are not supported in the .NET Framework so you would presumably have to have a native DLL in C++.

To add a context menu for a certain window, we have to capture
WM_CONTEXTMENU message. I believe other vendors do this also in their
programs.

To change all the context menu in windows for a certain kind of control, we
have to set a global hook for the message. In .NET, there are two major
components of the library. The first part is a C# class library which you
use directly in your application. That class library, in turn, uses an
unmanaged C++ DLL internally to manage the system hooks directly.

Here is an article for more information and a sample. HTH.

Have a look at these articles:
http://www.codeproject.com/csharp/GlobalSystemHook.asp
http://support.microsoft.com/?id=318804

This additional info led me to this Google Search that yielded also some interesting results.
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35475803
Mlanda...this is good info...but I have to create a distributed app..can I put these 'hooks' into an installer that the client can download?
0
 
LVL 31

Accepted Solution

by:
MlandaT earned 2000 total points
ID: 35688315
Yes. You could create your application such that it registers the hooks when it is first run or something of the sort. Or add a custom step to the installer - though this will depend on the capabilities provided by the application you are using to create the installer.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question