Sunday 13 December 2015

For Encrypt AND Decrypt Password

NAMESPACE Required:-

using System.Security.Cryptography;
using System.Text;
using System.IO;



FOR Encrypt:-
   private string Encrypt(string clearText)
    {
        string EncryptionKey = "MAKV2SPBNI99212";
        byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(clearBytes, 0, clearBytes.Length);
                    cs.Close();
                }
                clearText = Convert.ToBase64String(ms.ToArray());
            }
        }
        return clearText;
    }

​=-----------------------------------------------------------------------------
FOR ​
Decrypt
​:-
    private string 
​​
Decrypt(string cipherText)
    {
        string EncryptionKey = "MAKV2SPBNI99212";
        byte[] cipherBytes = Convert.FromBase64String(cipherText);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(cipherBytes, 0, cipherBytes.Length);
                    cs.Close();
                }
                cipherText = Encoding.Unicode.GetString(ms.ToArray());
            }
        }
        return cipherText;
    }

Friday 11 December 2015

Take Screen Shot Of Page

  1. using System;  
  2. using System.Drawing;  
  3. using System.Drawing.Imaging;  
  4. using System.Windows.Forms; 



  1. public static void Capture(string CapturedFilePath)  
  2.       {  
  3.          Bitmap bitmap = new Bitmap  
  4.        (Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);  
  5.   
  6.           Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);  
  7.           graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);  
  8.           
  9.           bitmap.Save(CapturedFilePath, ImageFormat.Bmp);  
  10.       }  





  1. protected void Button1_Click(object sender, EventArgs e)  
  2.        {  
  3.            Capture( "E:/ScreenShot.bmp");//path to Save Captured files  
  4.        } 

Monday 7 December 2015

Multiple CheckBox Select on Single CheckBox Select Using JQUERY

<script type="text/javascript">
        $(function () {
    $("#Gdtacking_ctl01_chkSelectAll").click(function () {       
        if ($("#Gdtacking_ctl01_chkSelectAll").is(':checked')) {
            $("input[type=checkbox]").each(function () {
                $(this).attr("checked", true);
               
            });

        } else {       
            $("input[type=checkbox]").each(function () {
                $("input[type=checkbox]").attr("checked", false);
               
            });
        }
    });
});
    </script>

Friday 4 December 2015

Drag & Drop File Upload Dialog with jQuery and Bootstrap



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

 <script src="bootstrap.fd.js" type="text/javascript"></script>
    <link href="bootstrap.fd.css" rel="stylesheet" type="text/css" />

    <script>
        $(document).ready(function () {
            $("#open_btn").click(function () {

                $.FileDialog({ multiple: true }).on('files.bs.filedialog', function (ev) {
                    var files = ev.files;

                    var data = new FormData();
                    for (var i = 0; i < files.length; i++) {
                        data.append(files[i].name, files[i]);
                    }
                    $.ajax({
                        url: "FileUploadHandler.ashx",
                        type: "POST",
                        data: data,
                        contentType: false,
                        processData: false,
                        success: function (result) {
                            alert(result);
                        },
                        error: function (err) {
                            alert(err.statusText)
                        }
                    });
                }).on('cancel.bs.filedialog', function (ev) {
                    alert("Cancelled!");
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <input type="button" id="open_btn" class="btn btn-primary" value="upload files">

    </div>
    </form>
</body>
</html>

Wednesday 2 December 2015

Disable first character in textbox Using Jquery

<input type="text" id="nameId" value="Given Name"/>


<script type="text/javascript">
    $(function(){
       $("#nameId").on("keydown", function(e) {
    if (($(this).get(0).selectionStart == 0 && (e.keyCode < 35 || e.keyCode > 40))
        || ($(this).get(0).selectionStart == 1 && e.keyCode == 8)) {
        return false;
}
});

$("#nameId").bind("contextmenu", function(e) {
    e.preventDefault();
});
    });
</script>