Click here to Skip to main content
Click here to Skip to main content

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

By , 22 Dec 2010
 

Introduction

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.

License

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

About the Author

$andesh M Patil
Software Developer (Senior)
India India
Member
Sandesh has a 6 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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberzhangtai19 Sep '12 - 17:14 
GeneralReason for my vote of 5 I learnt something new.memberkadu.sumit17 Jan '12 - 19:50 
GeneralReason for my vote of 5 Good Tipmembermandar130512 Sep '11 - 3:02 
GeneralReason for my vote of 2 Does not work in all browsersgroupKikoz6830 Aug '11 - 14:49 
Generalnicememberncik92 Aug '11 - 0:29 
GeneralReason for my vote of 4 http://ribbs.usps.gov/onecodesolutio...memberncik92 Aug '11 - 0:25 
GeneralReason for my vote of 5 inspired! Thanks ;]memberOmar Gamil28 Feb '11 - 9:12 
GeneralReason for my vote of 5 excellentmemberSumit Kumar Pranav27 Dec '10 - 6:56 
GeneralReason for my vote of 5 good onememberPranay Rana24 Dec '10 - 0:21 
GeneralYes it worksmemberSChristmas23 Dec '10 - 4:03 

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 22 Dec 2010
Article Copyright 2010 by $andesh M Patil
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid