Solved

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

Posted on 2011-03-08
20
307 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
 
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 30

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 30

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 30

Accepted Solution

by:
MlandaT earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now