Thursday 7 February 2013

Disable copy , cut and paste using c# in asp.net.


In this post I have explain how to disable copy , cut and paste using c# in asp.net without using java script.
Sometimes it is necessary to disable copy ,cut and paste function for textbox in web page or website. It is basically used in re-inter password or email account in registration page . So let’s do practically .

Open visual studion -> click on file -> open new website -> click on empty website ->  gie a project name  -> right click on solution -> add new item -> click on web page -> click ok.

Drage  a textbox on design page and write the three main  command in textbox.

1.) oncopy="return false"
2.) oncut="return false"
3.) onpaste="return false"

Design you page like this:-

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" oncut="return false"
            onpaste="return false" oncopy="return false" TextMode="MultiLine"
            BackColor="#669999" Height="103px" Width="445px"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Debuge the code and run.

Click here to download code. 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.