Click here to Skip to main content
11,575,635 members (58,501 online)
Click here to Skip to main content

Tagged as

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

, 22 Dec 2010 CPOL 26.9K 12
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

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)

Share

About the Author

Sandesh M Patil
Software Developer (Senior)
India India
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.

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
zhangtai19-Sep-12 17:14
memberzhangtai19-Sep-12 17:14 
GeneralReason for my vote of 5 I learnt something new. Pin
kadu.sumit17-Jan-12 19:50
memberkadu.sumit17-Jan-12 19:50 
GeneralReason for my vote of 5 Good Tip Pin
mandar130512-Sep-11 3:02
membermandar130512-Sep-11 3:02 
GeneralReason for my vote of 2 Does not work in all browsers Pin
Kikoz6830-Aug-11 14:49
groupKikoz6830-Aug-11 14:49 
Reason for my vote of 2
Does not work in all browsers
Generalnice Pin
ncik92-Aug-11 0:29
memberncik92-Aug-11 0:29 
GeneralReason for my vote of 4 http://ribbs.usps.gov/onecodesolutio... Pin
ncik92-Aug-11 0:25
memberncik92-Aug-11 0:25 
GeneralReason for my vote of 5 inspired! Thanks ;] Pin
Omar Gamil28-Feb-11 9:12
memberOmar Gamil28-Feb-11 9:12 
GeneralReason for my vote of 5 excellent Pin
Sumit Kumar Pranav27-Dec-10 6:56
memberSumit Kumar Pranav27-Dec-10 6:56 
GeneralReason for my vote of 5 good one Pin
Pranay Rana24-Dec-10 0:21
memberPranay Rana24-Dec-10 0:21 
GeneralYes it works Pin
SChristmas23-Dec-10 4:03
memberSChristmas23-Dec-10 4:03 
GeneralReason for my vote of 5 OK, I get it but if the user used Ct... Pin
Scofield Puzzle23-Dec-10 4:01
memberScofield Puzzle23-Dec-10 4:01 
GeneralOh its your sole opinion then, in large oranisation most of ... Pin
SChristmas21-Dec-10 6:23
memberSChristmas21-Dec-10 6:23 
GeneralYes, this works. But what difference does it make? I don't... Pin
wallkao3bei421-Dec-10 5:44
memberwallkao3bei421-Dec-10 5:44 
GeneralThanks a lot, very nice Tip Pin
melsheikh20-Dec-10 23:13
membermelsheikh20-Dec-10 23:13 
GeneralReason for my vote of 5 Thanks a lot, very nice Tip Pin
melsheikh20-Dec-10 23:13
membermelsheikh20-Dec-10 23:13 
GeneralThanks. Nice to know! Pin
Walt Fair, Jr.19-Dec-10 4:27
subeditorWalt Fair, Jr.19-Dec-10 4:27 
GeneralThanks kunal Pin
SChristmas26-Nov-10 4:27
memberSChristmas26-Nov-10 4:27 
GeneralReason for my vote of 5 Small but Good Tip. Keep posting reg... Pin
KunalChowdhury26-Nov-10 4:19
mvpKunalChowdhury26-Nov-10 4:19 
GeneralAn another knowledge i got from here...Thank you Smile Pin
kpl723-Nov-10 1:06
memberkpl723-Nov-10 1:06 
GeneralReason for my vote of 5 I learned new thing for sure and Tha... Pin
Sri Oleti19-Nov-10 9:44
memberSri Oleti19-Nov-10 9:44 
GeneralReason for my vote of 5 good tip. keep up the good work. Pin
Rakesh Agarwal ji19-Nov-10 2:29
memberRakesh Agarwal ji19-Nov-10 2:29 

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

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

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