65.9K
CodeProject is changing. Read more.
Home

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

Nov 18, 2010

CPOL
viewsIcon

71334

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.

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