December 16, 2016

Javascript vs Jquery


  • jQuery in itself is written in JavaScript.
  • JavaScript was first appeared on 1995 while jQuery was initially released in August 26, 2006.
  • JavaScript is an Object Oriented Programming (OOP) language while jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML.
  • JavaScript is a scripting language that works with all web browsers while jQuery is only a framework that is a fast and concise JavaScript library that simplifies the HTML document.
  • In case of using JavaScript you are required to writer your own script that can be time consuming. In case of using jQuery you are not required to write much scripting that already exists in libraries.
  • JavaScript is combination of both ECMA script and DOM while jQuery has DOM.
  • JavaScript has many processes in creating web-based applications while creating a web-based application with the help of jQuery has become easier.
  • Animations are not possible using JavaScript while these can be easily created using jQuery
  • jQuery support only Firefox, Google Chrome, Safari, Opera, and Internet Explorer while JavaScript is supported by all major web browsers without plug-ins.
javascript Jquery
function changeBackground(color) {
   document.body.style.background = color;
}
onload="changeBackground('red');"
$('body').css('background', '#ccc'); 
document.getElementById("example") $('#example')
document.getElementsByClassName("example") $('.example')
document.getElementById("btn")
.addEventListener("click", function () {
    document.getElementById("txtbox").value = "Hello World";
});
$('#btn').click(function () {
    $('#txtbox').val('Hello World');
});

datetime code


Dim dateString, format As String
dateString = "MM" & "/" & dd & "/" & yyyy & " " & HH & ":00"
dateString = dateString.Replace("-", "/")

Dim provider As CultureInfo = CultureInfo.InvariantCulture
format = "MM/dd/yyyy HH:mm:ss"
Try
   fromdate = Date.ParseExact(dateString, format, provider)
Catch ex As FormatException
   ShowAlert(ex.Message)
End Try

Generate Captcha in asp.net



Page : GenerateCaptcha.aspx

        protected void Page_Load(object sender, EventArgs e)
        {
            ClsWorkFlow objwork = new ClsWorkFlow();
            string strCaptcha = objwork.Decrypt(Request.QueryString["cap"]);

            Response.Clear();
            int height = 30;
            int width = 100;

            Bitmap bmp = new Bitmap(width, height);
            RectangleF rectf = new RectangleF(10, 5, 0, 0);
            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.White);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            Font f = new Font("Thaoma", 12, FontStyle.Italic);
            g.DrawString(strCaptcha, f, Brushes.Red, rectf);
            g.DrawRectangle(new Pen(Color.Red), 1, 1, width - 2, height - 2);
            g.Flush();
            Response.ContentType = "image/jpeg";
            bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
            g.Dispose();
            bmp.Dispose();
        }

Call the page 

        public void FillCapctha()
        {
            try
            {
                Random random = new Random();
                string combination = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                StringBuilder captcha = new StringBuilder();
                for (int i = 0; i <= 6; i++)
                {
                    captcha.Append(combination[random.Next(combination.Length)]);
                }
                ViewState["captcha"] = captcha.ToString();
                helper obj = new helper();
                ClsWorkFlow objwork = new ClsWorkFlow();
                imgCaptcha.ImageUrl = "GenerateCaptcha.aspx?cap=" + ViewState["captcha"].ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }