Wednesday, June 24, 2009

How to disable copy-paste functionality (cntrl C/V) in Asp.net textbox

As we know copy/paste can be done using either the right click of the mouse or using keys control+c, control+v etc.

So to disallow users to copy or paste we need to disable right click of the mouse as well as control+c, control+v on the required controls (textbox etc).

We can use javascript to disable right mouse click or ctrl keys to ensure user is not able to copy paste in a textbox
we can achieve this in 2 ways

1. use this method when you don't want any alerts or message

<asp:TextBox ID="TextBox1" runat="server"
oncopy="return false"
onpaste="return false"
oncut="return false">
asp:TextBox>

2. If you want to show alerts than use this method instead

Right this javascript function in the head section of aspx page, in
this function we are disabling right mouse click and ctrl keys

function DisableCopyPaste()
{
alert("This functionality has been disabled !");
window.clipboardData.clearData("Text"); //for cleaning up the clipboard
// Cancel default behavior
event.returnValue = false;
}
First register the event handlers for copy & paste events on this textbox.

This can be done in Page_Load() event handler as:

protected void Page_Load(object sender, EventArgs e)
{
//for paste
txtFname.Attributes.Add("onpaste", "JavaScript: DisableCopyPaste();");

//for copy
txtFname.Attributes.Add("oncopy", "JavaScript: DisableCopyPaste();");

}

Thursday, March 26, 2009

Disable or Enable USB Port

To Disable
Open regedit from run command and goto the following path
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR]
Now in the right pane, double-click Start and type 4 in the Value data box (Hexadecimal) and quite the registry editor.
To enable
Change the Start value back to 3.

Multiple Profiles in yahoo Messenger

Multiple login in yahoo without using any SoftwareYou can login with multiple id's on thesame yahoo messenger without any download or patch .Follow these steps :1. Go to Start ----> Run .Type regedit, then enter .2.Navigate toHKEY_CURRENT_USER--------> Software--->yahoo----->pager---->Test3.On the right page , right-click andchoose new Dword value .4.Rename it as Plural.5.Double click and assign a decimal value of 1.Its done!!Now close registry andrestart yahoo messenger and try Multiple Login

Wednesday, February 11, 2009

Regular expression

In computing, Regular Expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.


Wednesday, January 14, 2009

Multiple Profiles in Firefox


Step 1:open system properties(by right clicking my computer),
choose tab advanced,
click to environment variables button. in system variables section,
click new.
type this information to each textbox.
variable name: moz_no_remote(should be all small letter)
variable value: 1
press ok to close all windows.


step 2:open firefox icon's properties(from desktop and quick launch). add extension -p to command line(like "c:\program files\mozilla firefox\firefox.exe" -p). press ok.
while starting firefox u have to create two separate profiles of firefox so that u can login to two accounts of any(orkut,yahoo,rediff or anything else).......for three logins create three profiles of firefox.........