If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Mouseclicks over a listbox: JavaScript or Asp.Net?

Hello,

Firstly, apologies about posting a similar problem because there have been different answers on what language and approach to take. This time, I'll try to describe the problem clearer.

In short, I have to display a rightclick menu only when the user rightclicks on a list item in a listbox. If the mouse is not at a list item, the menu will not appear when the user right clicks the mouse.

The listbox is an asp.net control, not a vb forms one. It is part of a custom control which consists of the asp.net listbox, a context menu and a label. The context menu is itself a custom control developed using c#, not one which is created by javascript. However, there is a javascript file which is included in the context menu code which is responsible for displaying the menu at where the user right clicks.

Hence, my custom control consists of 2 asp.net controls and another custom contro(a context menu having c# and javascript coding).

Are there any advice on how to let the asp.net listbox and javascript work together to display the menu only at the list items?

Re: Mouseclicks over a listbox: JavaScript or Asp.Net?

Well, to start the page off you could declare a JavaScript variable named mnuenabled and set it to false. Now use onmouseover and onmouseout for the items you want to be enabled on the menu. In that onmouseover routine set the mnuenabled to true and onmouseout should be set to return the variable to false. Now only show the right-click menu when the variable is true.

If the post was helpful...Rate it! Remember to use [code] or [php] tags.