如何在asp.net页面中允许复制粘贴 [英] How to allow Copy paste in asp.net page

查看:239
本文介绍了如何在asp.net页面中允许复制粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的WebApplication中,我限制用户从/向文本框复制和粘贴内容。

但在其中一个网页中我需要允许复制/粘贴在1个文本框中。



我在主页面中使用Javascript -

Hi All,
In my WebApplication I have restricted user from copying and pasting content from/ to Text Box.
but in one of webpage i need to allow copy/ paste in 1 textbox.

I'm using Javascript in Master page-

<script type="text/javascript">

             document.onkeydown = function() {

           // JavaScript code to handle keys

   </script>



有谁能建议我怎么做?





谢谢,


can anyone suggest how do i do it?


Thanks,

推荐答案

限制网页上的剪贴板副本将是巨大的,巨大的滥用行为违反了大多数基本客户权利。由于Web标准,这绝对是不可能的。问题是:你正在谈论完全在客户端的一些操作。一旦在客户端主机上呈现某些页面内容,它就已完全在该主机上并属于客户端。客户无需成为软件工程师即可解决您的限制。对于您的用户来说,使用Web并不是一个完整的白痴就足够了。



因此,你只是在浪费时间做一些事情对于试图复制剪贴板的用户来说非常烦人,同时,绝对无法保护您的信息。



不要做坏事。



-SA
Restricting clipboard copy on the Web page would be huge, huge abuse brutally violating most basic customer rights. Thanks to the Web standards, this is absolutely impossible to do. The thing is: you are talking on some operations which are fully on the client side. As soon as some page content is rendered on the client host, it is already fully on that host and belongs to the client. The customer does not have to be a software engineer to work around your limitation. For your user, it would be enough to have certain level of experience with using Web and not being a complete moron.

Therefore, you are just wasting time doing something which is highly annoying to the user trying to do the clipboard copy and, at the same time, absolutely cannot protect your information.

Don't do evil.

—SA


您必须修改代码。正如SA所说,这是一种不好的做法,即使有些网站也这样做。您可以传入文本框ID,也可以查看您所在的页面。一种方式,你必须决定,你需要修改代码。
You'll have to modify your code. As SA says, it is a bad practice, even though some sites do it. You could pass in the textbox ID or perhaps see what page you are on. One way, and you'll have to decide, you need to modify the code.


根据你的问题,我可以看到下面将是最简单的方法。



如果您创建2个母版页,其功能是禁用复制和粘贴,而另一个没有相同的

两个母版页都是彼此的复制品。



MASTER PAGE 1

(禁止复制粘贴)

- 然后跟随其所有页面



MASTER PAGE 1

(启用复制粘贴)

- 然后跟随其所有页面
As per your question I can see that below will be the simplest way.

It would be better if you create 2 master pages on with the functionality of disabling the copy and paste and another without the same
Both of the master pages will be replica of each other.

MASTER PAGE 1
(COPY PASTE DISABLED)
-Then Followed with all of its pages

MASTER PAGE 1
(COPY PASTE ENABLED)
-Then Followed with all of its pages


这篇关于如何在asp.net页面中允许复制粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆