Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
c# ASPNET rightclick event
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Permudious" data-source="post: 481836" data-attributes="member: 55273"><p>Goodmorning Guys,</p><p></p><p>I am developing a webpage which works fine.</p><p>Now I would like to create a right click event, I did already some research. but can't find the solution which will fit for me.</p><p></p><p>When I rightclick on a button I would like to see the name of the button, but when I do this on the second button I still see the name of the first button.</p><p></p><p>[ATTACH=full]15865[/ATTACH]</p><p></p><p>My code:</p><p></p><p>[CODE=aspnet]<div class="nac"></p><p> @foreach(var Person in Model.Persons.Where(x => x.FrstName == "Katherine" || x.FrstName == "Jane" ))</p><p> {</p><p> string Cardholder = "";</p><p> if (Person.MiddleName == "") { Cardholder = Person.LastName + ", " + Person.FrstName; } else if (Person.MiddleName != null) { Cardholder = Person.LastName + " " + Person.MiddleName + ", " + Person.FrstName; } else { Cardholder = Person.LastName + ", " + Person.FrstName; }</p><p></p><p> <button id="item" class="na">@Cardholder<p class="rmlv">OUT</p></button></p><p></p><p> <div id="myDiv" style="display: none;"></p><p> <a href="#" class="close" onclick="closeMessage('message-balloon1')">&times;</a></p><p> <p class="title">Change State</p></p><p> <p class="subtitle">@Cardholder</p></p><p> </div></p><p> }</p><p></div>[/CODE]</p><p></p><p>[CODE=javascript]<script></p><p> document.addEventListener('contextmenu', function (e) {</p><p> e.preventDefault();</p><p> var div = document.getElementById('myDiv');</p><p> div.style.left = e.pageX + 'px';</p><p> div.style.top = e.pageY + 'px';</p><p> div.style.display = 'block';</p><p> });</p><p></p><p> document.addEventListener('click', function () {</p><p> var div = document.getElementById('myDiv');</p><p> div.style.display = 'none';</p><p> });</p><p></p><p> var closebtns = document.getElementsByClassName("close");</p><p> var i;</p><p></p><p> for (i = 0; i < closebtns.length; i++) {</p><p> closebtns[i].addEventListener("click", function () {</p><p> this.parentElement.style.display = 'none';</p><p> });</p><p> }</p><p></script>[/CODE]</p></blockquote><p></p>
[QUOTE="Permudious, post: 481836, member: 55273"] Goodmorning Guys, I am developing a webpage which works fine. Now I would like to create a right click event, I did already some research. but can't find the solution which will fit for me. When I rightclick on a button I would like to see the name of the button, but when I do this on the second button I still see the name of the first button. [ATTACH type="full"]15865[/ATTACH] My code: [CODE=aspnet]<div class="nac"> @foreach(var Person in Model.Persons.Where(x => x.FrstName == "Katherine" || x.FrstName == "Jane" )) { string Cardholder = ""; if (Person.MiddleName == "") { Cardholder = Person.LastName + ", " + Person.FrstName; } else if (Person.MiddleName != null) { Cardholder = Person.LastName + " " + Person.MiddleName + ", " + Person.FrstName; } else { Cardholder = Person.LastName + ", " + Person.FrstName; } <button id="item" class="na">@Cardholder<p class="rmlv">OUT</p></button> <div id="myDiv" style="display: none;"> <a href="#" class="close" onclick="closeMessage('message-balloon1')">×</a> <p class="title">Change State</p> <p class="subtitle">@Cardholder</p> </div> } </div>[/CODE] [CODE=javascript]<script> document.addEventListener('contextmenu', function (e) { e.preventDefault(); var div = document.getElementById('myDiv'); div.style.left = e.pageX + 'px'; div.style.top = e.pageY + 'px'; div.style.display = 'block'; }); document.addEventListener('click', function () { var div = document.getElementById('myDiv'); div.style.display = 'none'; }); var closebtns = document.getElementsByClassName("close"); var i; for (i = 0; i < closebtns.length; i++) { closebtns[i].addEventListener("click", function () { this.parentElement.style.display = 'none'; }); } </script>[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
c# ASPNET rightclick event
Top