Asp.net 如何在文本框中禁用复制和剪切?

Asp.net 如何在文本框中禁用复制和剪切?,asp.net,webpage,Asp.net,Webpage,在我的网页中,我想禁用文本框上下文菜单中的复制和剪切选项。 <asp:TextBox ID="TextBox1" runat="server" oncopy="return false"> </asp:TextBox> 试试这个 <asp:TextBox ID="txtPrevent" runat="server" oncopy="return false" oncut="return false"> <

在我的网页中,我想禁用文本框上下文菜单中的复制和剪切选项。


<asp:TextBox ID="TextBox1" runat="server" oncopy="return false">  </asp:TextBox>
试试这个

     <asp:TextBox ID="txtPrevent" runat="server"  oncopy="return false"
         oncut="return false">
        </asp:TextBox>

您还可以添加javascrip函数来显示警报

    <script language="javascript" type="text/javascript">
            function nocopy()
    {
                alert("Copying is not allowed!");
                return false;
    }
   </script>

函数nocopy()
{
警告(“不允许复制!”);
返回false;
}


这是我的第一篇文章,希望能有所帮助。 试试这个:

<asp:TextBox ID="someId" runat="server" oncopy="return false" onpaste="return false" oncut="return false" ondelete="return false"></asp:TextBox>


它可以在大多数输入控件上进行复制、粘贴、剪切和删除。

不确定您是否在寻找非asp方式,但我刚刚在JavaScript中发现了on-cut方法。对您的输入执行以下操作:

<input oncopy='prevent()>

<script>
function prevent()
{
 event.preventDefault();
}
</script>

意味着你不想让用户右键点击,或者你想处理Cntrl+C,如果有人想这么做,他们会找到办法的。无法确保无法从网页复制数据。哪些浏览器支持oncopy事件?@DaveB我已经在IE8和Firefox以及Chrome上对其进行了测试。塔克斯。
<input oncopy='prevent()>

<script>
function prevent()
{
 event.preventDefault();
}
</script>