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>

Tuesday 3 November 2015

Check Duplicate value in dynamic Text box using jquery

<script type="text/javascript">
        function findDuplicates() {
           
            var isDuplicate = false;
            jQuery("input.access_keys[type=text]").each(function (i,el1) {
           
                var current_val = jQuery(el1).val();
                if (current_val != "") {
                    jQuery("input.access_keys[type=text]").each(function (i,el2) {
                        if (jQuery(el2).val() == current_val && jQuery(el1).attr("name") != jQuery(el2).attr("name")) {
                            isDuplicate = true;
                            jQuery(el2).css("background-color", "yellow");
                            jQuery(el1).css("background-color", "yellow");
                           
                            return;
                        }
                    });
                }
            });

            if (isDuplicate) {
                alert ("Same Accession no can not be issued more than 1 member.");
                jQuery("input.access_keys[type=text]").val('');
                return false;
            } else {
                return true;
            }
        }
    </script>

Monday 25 May 2015

Limit Textbox character After Comma (1234,4567)

function checkNumberWithComma(textBox) {
if ((textBox.value == 0 || textBox.value) && textBox.value.match(/^\d{4,4}(

?:,\d{4})*$/)) {
$(textBox).removeClass("error"
);
}
else {
$(textBox).addClass("error");
}
}
function testFunc() {
checkNumberWithComma(document.
getElementById("test"));
}
$(document).ready(function() {
document.getElementById("
testButton").onclick = testFunc;
});

Lazy Load Image

Link these Files:-
<meta charset='utf-8' />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>Untitled Page</title>
    <link href="http://www.jqueryscript.net/demo/Super-Easy-jQuery-Content-Lazy-Load-Plugin-LazyContent/style.css"
        media="all" rel="stylesheet" type="text/css" />

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="http://www.jqueryscript.net/demo/Super-Easy-jQuery-Content-Lazy-Load-Plugin-LazyContent/src/jquery.lazy_content.js"></script>


Code.aspx:-

<div class="container">
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/1"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/1"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/2"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/2"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/3"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/3"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/4"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/4"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/5"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/5"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/6"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/6"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/7"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/7"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/8"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/8"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/9"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/9"> </div>
</section>
            <section>
<div class="loading"> <span>Loading...</span> </div>
<div class="content"> <img class="lazy" data-src="http://lorempixel.com/250/250/abstract/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/city/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/people/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/transport/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/animals/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/food/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/nature/10"> <img class="lazy" data-src="http://lorempixel.com/250/250/business/10"> </div>
</section>
        </div>

        <script charset="utf-8">
      $("section").lazyContent({
        threshold: 0,
        load: function(element) {
          element.find(".loading").hide();
          element.find("img").each(function() {
            var $img = $(this);
            $img.attr("src", $img.data("src"));
            $img.load(function() { $img.addClass("loaded") });
          });

          element.find(".content").show();
        }
      });
        </script>

Friday 27 March 2015

Create Procedure in Oracle

CREATE OR REPLACE Procedure UpdateCourse
   ( name_in IN varchar2 )
  
IS
   cnumber number;

   cursor c1 is
   SELECT course_number
    FROM courses_tbl
    WHERE course_name = name_in;

BEGIN

   open c1;
   fetch c1 into cnumber;

   if c1%notfound then
      cnumber := 9999;
   end if;
  
   INSERT INTO student_courses
   ( course_name,
     course_number )
   VALUES
   ( name_in,
     cnumber );

   commit;

   close c1;

EXCEPTION
WHEN OTHERS THEN
   raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;