Solved

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

Posted on 2011-03-08
20
306 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

19 Experts available now in Live!

Get 1:1 Help Now