2012-08-06 129 views
1

我想阻止用户从网格单元的数据复制的DevExpress网格MVC 3剃须刀

我用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; 
} 

能正常工作在谷歌Chrome,莫兹火狐,歌剧,但在IE不


enter image description here

我想用户不能选择整个网格像这是我写的不是工作在IE的图片

CSS只

+0

你可以使用jQuery吗? – 2012-08-06 08:33:57

+0

是的,我可以使用Jquery – 2012-08-06 08:39:08

+0

,这是因为IE以任何方式对CSS有蹩脚的支持。 jQuery解决方案没有工作吗? – 2012-08-06 08:59:02

回答

2

我找到了解决方案

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

这也适用于IE

+0

您可以批准您的帖子为答案以关闭此票证。 – Mikhail 2012-08-07 16:29:18

1

,如果你可以使用jQuery,你可以尝试从pkarl this解决方案:

<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; 
} 

+0

我不仅要防止复制也要防止选择 – 2012-08-06 11:29:09