1

I want to prevent users from copying data from grid cells

I used css

td.dxgv
{   
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-user-select: none;
}

this works fine in Google Chrome, Moz FireFox, Opera but in IE not


enter image description here

I want that users cannot select whole grid like on the picture

css which I wrote not working in IE only

ChrisF
  • 134,786
  • 31
  • 255
  • 325
Adam Bremen
  • 685
  • 1
  • 7
  • 18

2 Answers2

2

I found solution

<div id="applicationList" class="applicationList" onselectstart="return false;">
        @Html.Partial("_List", Model)
</div>

this works in IE too

Adam Bremen
  • 685
  • 1
  • 7
  • 18
1

if you can use jquery, you could try this solution from pkarl:

<script src="http://www.google.com/jsapi"></script> 
<script type="text/javascript">
    google.load("jquery", "1");
</script>

<script type="text/javascript"> 

$(function() {

    // We check for a text selection when someone right-clicks
    $(document).bind('contextmenu', checkSelection);

    // We also check for a text selection if ctrl/command are pressed along w/certain keys
    $(document).keydown(function(ev) {

        // capture the event for a variety of browsers
        ev = ev || window.event;

        // catpure the keyCode for a variety of browsers
        kc = ev.keyCode || ev.which;

        // check to see that either ctrl or command are being pressed along w/any other keys
        if((ev.ctrlKey || ev.metaKey) && kc) {

            // these are the naughty keys in question. 'x', 'c', and 'c'
            // (some browsers return a key code, some return an ASCII value)
            if(kc == 99 || kc == 67 || kc == 88) {
                return checkSelection()
            }

        }

    });

})

// check to see if anything is currently highlighted by the visitor. If so, return false.
function checkSelection() {
    if (window.getSelection) { var userSelection = window.getSelection(); } 
    else if (document.selection) { var userSelection = document.selection.createRange(); }
    if(userSelection != '') return false;
}

kalbsschnitzel
  • 817
  • 1
  • 8
  • 29