Click here to Skip to main content
13,447,852 members (54,140 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


13 bookmarked
Posted 18 Nov 2010

How to Prevent a Drag and Drop Text and Copy Paste Text in your textbox Control

, 22 Dec 2010
Rate this:
Please Sign up or sign in to vote.
How to prevent a drag and drop text and copy paste text in your textbox control


You can prevent a drag and drop value from your page and a copy paste text in your textbox.

For example: I have a textbox:

<asp:TextBox ID="txtSeqNumber" runat="server"  Width="150">

How can I prevent this? Most of the time, this error is reported by testers. The simplest solution is as follows.

Just add the following JavaScript in the code:

<asp:TextBox ID="txtSeqNumber" runat="server" onDrop="blur();return false;" 

	onpaste="return false"  Width="150">

Because of blur() function, the txtSeqNumber lost its focus and we are not able to drag and drop the text.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sandesh M Patil
Team Leader
India India
Sandesh has a 8 years of total professional experience in a software development. He first handled the computer in his school days when he was in 7th std working on Lotus. In summer vacation, the school authorities allowed him and other students to use the computers for practicing Lotus and playing different games Smile | :) .

He has done computer engineering. Currently he is working in Net 4.0 framework. Even though he is using .Net 4.0 framework for development but still he has not got a chance to work with newer technologies like MVC, WCF etc. However he always try to learn these technologies from his end and eagerly waiting for a chance to work with the newer technologies like MVC, WCF and Silverlight etc.

You may also be interested in...


Comments and Discussions

GeneralReason for my vote of 5 excellent Pin
Sumit Kumar Pranav27-Dec-10 6:56
memberSumit Kumar Pranav27-Dec-10 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04-2016 | 2.8.180318.3 | Last Updated 22 Dec 2010
Article Copyright 2010 by Sandesh M Patil
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid