- Embedded within HTML : Java Script does not require any separate editor for programs to be written, edited or compiled. It can be written in any text editor like Notepad, along with appropriate HTML tag and saved as filename.html. HTML files with embedded Java Script commands can then be read and interpreted by any browser that is Java Script enabled.
- An Interpret Language : Java Script is an interpreted language i.e, no compilation is needed. The syntax is completely interpreted by a browser just as it interprets HTML tags. This provides an easy development process.
- Minimal Syntax - Easy to Learn : By learning few commands and simple rules of syntax, complete applications can be built using Java Script.
- Designed for Simple, small Programs : It is well suited to implement simple, small programs( for example, a program to apply all arithmetic operation on two numbers). Such programs can be easily written and executed using Java Script. They can be easily integrated into a web page.
- Quick Development : Java Script does not require time-consuming compilation, so scripts can be developed in a short period of time. This is the reason that many GUI interface features such as alerts, confirm boxes, prompts, and other GUI elements, are handled by client side Java Script, the browser and HTML code.
- Procedural Capabilities : Every programming language needs to support facilities such as condition checking, Branching and looping Java Script provides syntax, which can be used to add such procedural capabilities to web page coding.
- Performance : Java Script can be written such that the HTML files are fairly compact and quite small. This minimizes storage requirements on a web server and download time for the client.
- Event Handling : Java Script supports object or Event based programming. Java Script recognizes when a form 'Button' is pressed. The event can have suitable JavaScript code attached, which will execute when the 'Button Pressed' event occurs.
- Event handling : Java Script can be used to implement context sensitive help. Whenever in a HTML form's mouse cursor moves over a button or a link on the page, a helpful and informative message can be displayed in the status bar at the bottom of browser window.
- Platform Independence and Architecture Neutral : Java Script is a programming language that is completely independent of the hardware on which it works . It is a Language that is understood by any Java Script enabled web browser. Thus, Java Script application works on any machine that has an appropriate Java Script enabled web browser.
- A Java Script program developed on a window machine will work perfectly well on a Unix machine.
- A platform specific browser, maintained at client end, does the interpretation of Java Script, relieves the developer from the responsibility of maintaining multiple source code files for multiple platform.
- Easy Testing and Debugging : Being an interpreted language, Java Script scripts are tested line by line, and errors are also listed as they are encountered, i.e. an appropriate error message along with line number is listed for every error that is encountered. It is thus easy to locate errors, make changes, and test it again without the overhead and delay of compiling.
Monday, April 6, 2015
Sunday, April 5, 2015
Functions Provided by Java Script
- Java Script can put dynamic text into an HTML page- using HTML, you can produce only static pages but javascript add dynamic functionality in HTML. A javascript statement like this: document.write("<h1>"+name+"</h1>") can write a variable text into an HTML page.
- JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but javascript is a scripting language with a very simple syntax. Almost anyone can put small "snippets" of code into their HTML page.
- JavaScript can be used to Validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing.
- JavaScript can react to events - Java script provide the concepts of events handling. A JavaScript can be set to execute when something happens like when a page has finished loading or when a user clicks on an HTML element. Eg button.
- Java Script can read and write HTML elements- A JavaScript can read and change the content of an HTML element.
- Java Script can be used to detect the visitor's browser - A Java Script can be used to detect the visitor's browser, and - depending on the browser-load another page specifically designed for the browser.
- Java Script can be used to create cookies - A Java Script can be used to store and retrieve information on a visitor's computer.
Introduction to Java Script
Java Script is used in many of Web pages to improve the design, validate forms and create cookies.
JavaScript is the popular scripting language on the internet, and works in all major browser, such as Internet Explorer, Opera and Firefox.
JavaScript, despite the name, is essentially not related to Java programming language, both have the common C syntax, and JavaScript copies many Java names and naming conversions. The language was initially named "LiveScript" but was renamed in a co-marketing deal between Sun and Netscape in exchange for Netscape bundling Sun's Java runtime with their dominant browser. key design principles within JavaScript are inherited from the Self and Scheme programming languages.
History
JavaScript was developed by Brendan Eich of Netscape under the name Mocha, which was later renamed to 'LiveScript', and finallt to JavaScript. Change of name from LiveScript to JavaScript roughly coincided with Netscape adding support for Java technology in its Netscape navigator web browser. JavaScript was first introduced in the Netscape browser version 2.0B3 in December 1995. Naming was caused confusion, giving the impression that language is a spin -off of Java, and it has been characterized by many as a marketing ploy by Netscape to give JavaScript the cachet of what was then the hot new web -programming language.
Microsoft named its dialect of language JScript to avoid trademark issues. JScript was first supported in Internet Explorer version 3.0 released in August 1996, and it included Y2K-compliant date functions, unlike those based on java.util.Date in JavaScript at the time. Dialects are perceived to be so similar that the terms "JavaScript" and "JScript" are often used interchangeably Microsoft notes dozens of ways in which JScript is not ECMA complaint.
Netscape submitted JavaScript to ECMA International for standardization resulting in standardized version named ECMAScript.
JavaScript
- Java Script is a scripting language.
- Java Script was designed to add interactivity to HTML pages.
- A Scripting language is a lightweight programming language.
- Java Script is an interpreted language (means that scripts execute without preliminary compilation)
- Java Script is usually embedded directly into HTML pages.
- Everyone can use Java Script without purchasing a licence.
Writing Javascript into HTML
JavaScript syntax is embedded into HTML file. A Browser reads HTML files and interprets HTML tags. Since all JavaScripts need to be included as an integral part of an HTML document when required, the browser needs to be informed that specific sections of HTML code is JavaScript. The Browser will then use its built-in JavaScript engine to interpret this code.
The Browser is given this information using HTML tags <SCRIPT>....</SCRIPT>. The <SCRIPT> tag marks the beginning of a snippet of scripting code. The paired </SCRIPT> marks the end of a snippet of script code.
The <SCRIPT> tag takes an optional attribute, as listed below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script type ="text/javascript" >
document.write("Hello World!");
</script>
</body>
</html>
The Browser is given this information using HTML tags <SCRIPT>....</SCRIPT>. The <SCRIPT> tag marks the beginning of a snippet of scripting code. The paired </SCRIPT> marks the end of a snippet of script code.
The <SCRIPT> tag takes an optional attribute, as listed below:
Attributes
|
Description
|
Language
|
Indicates the scripting language used for writing the snippet
scripting code. It can take following values:
1. JavaScript
2. VBScript
|
Syntax:
<script language="javascript">
<!-- JavaScript statements
// -->
</script>
For example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script type ="text/javascript" >
document.write("Hello World!");
</script>
</body>
</html>
The code above will produce this output on an HTML page:
To insert a JavaScript into an HTML page, we use the <script> tag. Inside the <script> tag we use the type attribute to define scripting language.
So, the <script type="text/javascript"> and </script> tells where a JavaScript starts and ends.
The word document.write is a standard JavaScript command for writing output to a page.
By entering the document.write command between the <script> and </script> tags. the browser will recognize it as a JavaScript command and execute the code line. In this case the browser will write Hello World! to the page.
World clock app for window phone 8 c#
Introduction
If you want to know time at any location in the world, use this app in windows phone. This app offers numbers of features, including an interactive time zone list. Select any time zone, which is given in the list and check it. No advertisements are shown in this app. Basically This app is designed for beginners, who want to know about windows phone app development.How to Install it in windows phone
- Download the mentioned package
- Use .xap file for running it.
Learn How to design it
To create a new app in windows phone 8, the steps are listed below:- Create a new project by going through File | New Project | Windows Phone Application - Visual C#. Give a desired project name( World Clock is my app name).
- From Solution Explorer, open MainPage.xaml file. (If Solution Explorer is currently not opened then open it via View>>Other Windows>> Solution Explorer).
- Change name of your header text, which is in TextBlock(Inside stack panel).
- Add a listbox control in the grid panel control. Also bind from ItemSource property.
- Add a class in the project, which name is "timezone.cs". Add two public property inside in it. Now, code look like
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WorldClock { class timezone { public String timename { get; set; } public string ImagePath { get; set; } } }
List chemists = new List();
chemists.Add(new timezone() { timename = "UTC-12:00 Internatioanl Date Line West", ImagePath = "image/Internatioanl Date Line West.jpg" });
chemists.Add(new timezone() { timename = "UTC-11:00 Coordinated Universal Time-11", ImagePath = "image/Internatioanl Date Line West.jpg" });
chemists.Add(new timezone() { timename = "UTC-10:00 Hawaii", ImagePath = "image/hawaii.jpg" });
chemists.Add(new timezone() { timename = "UTC-09:00 Alaska", ImagePath = "image/Alaska.gif" });
chemists.Add(new timezone() { timename = "UTC-08:00 Baja California", ImagePath = "image/bajaflag.jpg" });
chemists.Add(new timezone() { timename = "UTC-08:00 Pacific Time(US & Canada)", ImagePath = "image/uscan.jpg" });
7. Now, use DispatcherTimer class for update the time with 1 sec. Now, use this code for update the time
DispatcherTimer newTimer = new DispatcherTimer();
newTimer.Interval = TimeSpan.FromSeconds(1);
newTimer.Tick += OnTimerTick;
newTimer.Start();
void OnTimerTick(Object sender, EventArgs args)
{
clocklabel.Text = DateTime.Now.ToString();
}
8 .Create the code for each index of ListBox also display the result on MessageBox.
private void lstCountries_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch (list1.SelectedIndex)
{
case 0: MessageBox.Show(dt.AddMinutes(-720).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
case 1: MessageBox.Show(dt.AddMinutes(-660).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
case 2: MessageBox.Show(dt.AddMinutes(-600).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
case 3: MessageBox.Show(dt.AddMinutes(-540).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
case 4: MessageBox.Show(dt.AddMinutes(-480).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
case 5: MessageBox.Show(dt.AddMinutes(-480).ToString() + TimeZoneInfo.Utc.DaylightName);
break;
}
}
9. Run this app in Emulator WVGA 512mb, now code will generate the output.When you select any item from the given list then phone emulator display the time according to the time zone. Basically this system designed on UTC time.
Saturday, April 4, 2015
SignIn after registration in ASP.NET
In my previous article, we have already learned that how to create registration page in asp.net 4.5. Today we talk about signin after registration. Simple API provided by the microsoft that is Microsoft.AspNet.Identity, various methods and classes given init by the microsoft, such as UserManager class etc . After successfully registration you can check, whether the registration is success or not using IdentityResult class. If IdentityResult class return true then you will signin into the account using static method of SignIn, which is available in IdentityHelper class. Now, code of your application is
IdentityResult result = manager.Create(user, Password.Text);
if (result.Succeeded)
{
IdentityHelper.SignIn(manager, user, isPersistent: false);
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
}
The Simple static SignIn method of IdentityHelper class is
public static void SignIn(UserManager manager, ApplicationUser user, bool isPersistent)
{
IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
After signin you can redirect to other page. A very simple method provided by the microsoft that is RedirectToReturnUrl (static), which is also available in IdentityHelper class that is
public static void RedirectToReturnUrl(string returnUrl, HttpResponse response)
{
if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl))
{
response.Redirect(returnUrl);
}
else
{
response.Redirect("~/");
}
}
Business Objects as model in MVC
We have to already implement mvc project to retrive data with the help of model folder. Today, we will discuss about business objects as model in MVC. First to implement the business logic in the separate project. Add a new class library project in the solution, also Add two class in it.
First class that is, department.cs. Copy this code and paste into your department.cs file.
model
Add a reference of the class library project into the MVC project. Add a department controller in the controller folder. Through which, we will retrieve list of data. Copy this code and paste into your DepartmentController class.
Note : Select List as a Template, also select department as model class which is inside in Library class project. After adding the view in the MVC project.
Now run your application, without any changes in the View. Now, Your code generate the following output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessModel
{
public class department
{
public int Id { get; set; }
public string Name { get; set; }
}
}
Code define the department table properties that is Id and Name. Second class that is, BusinessLayermodel.cs. Copy this code and paste into your BusinessLayermodel.cs file
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
namespace BusinessModel
{
public class BusinessLayermodel
{
public IEnumerable<department> departments
{
get
{
List<department> dept = new List<department>();
SqlConnection con = new SqlConnection();
con.ConnectionString= ConfigurationManager.ConnectionStrings ["EmployeeConnection"].ToString();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from [Department]";
cmd.Connection = con;
SqlDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
department dt = new department();
dt.Id=Convert.ToInt32(rd[0].ToString());
dt.Name = rd[1].ToString();
dept.Add(dt);
}
return dept;
}
}
}
}
In this code, we have a public class BusinessLayermodel with single public property that is departments. This class work as context class, through this, we can access data from the database table by the public property of departments . Comparison between business layer model v/s MVC model
Add a reference of the class library project into the MVC project. Add a department controller in the controller folder. Through which, we will retrieve list of data. Copy this code and paste into your DepartmentController class.
using BusinessModel;
namespace WebApplication11.Controllers
{
public class DepartmentController : Controller
{
//
// GET: /Department/
public ActionResult Index()
{
BusinessLayermodel blt = new BusinessLayermodel();
List<department> dept = blt.departments.ToList();
return View(dept);
}
}
}
Build the project before adding the view in the MVC project. Right click on your controller class, Add new view by the snap shot.Note : Select List as a Template, also select department as model class which is inside in Library class project. After adding the view in the MVC project.
Now run your application, without any changes in the View. Now, Your code generate the following output







