Thursday, December 23, 2010

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 ex. I have a textbox


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

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

Just add 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 darg and drop the text.
 
 

No comments :

Post a Comment