Pages

27 Oct 2013

ASP.NET MVC - Application Folders

To learn ASP.NET MVC, we are Building an Internet application
Part II: Exploring the Application Folders

MVC Folders

A typical ASP.NET MVC web application has the following folder content:
Solution  Application information
Properties
References
Application folders
App_Data Folder
Content Folder
Controllers Folder
Models Folder
Scripts Folder
Views Folder
Configuration files
Global.asax
packages.config
Web.config
The folder names are equal in all MVC applications. The MVC framework is based on default naming. Controllers are in the Controllers folder, Views are in the Views folder, and Models are in the Models folder. You don't have to use the folder names in your application code.
Standard naming reduces the amount of code, and makes it easier for developers to understand MVC projects.
Below is a brief summary of the content of each folder:

The App_Data Folder

The App_Data folder is for storing application data.
We will add an SQL database to the App_Data folder, later in this tutorial.

The Content Folder

The Content folder is used for static files like style sheets (css files), icons and images.
Visual Web Developer automatically adds a themes folder to the Content folder. The themes folder is filled with jQuery styles and pictures. In this project you can delete the themes folder.
Visual Web Developer also adds a standard style sheet file to the project: the file Site.css in the content folder. The style sheet file is the file to edit when you want to change the style of the application.
Content
We will edit the style sheet file (Site.css) file in the next chapter of this tutorial.

The Controllers Folder

The Controllers folder contains the controller classes responsible for handling user input and responses.
MVC requires the name of all controller files to end with "Controller".
Visual Web Developer has created a Home controller (for the Home and the About page) and an Account controller (for Login pages):
Controllers
We will create more controllers later in this tutorial.

The Models Folder

The Models folder contains the classes that represent the application models. Models hold and manipulate application data.
We will create models (classes) in a later chapter of this tutorial.

The Views Folder

The Views folder stores the HTML files related to the display of the application (the user interfaces).
The Views folder contains one folder for each controller. 
Visual Web Developer has created an Account folder, a Home folder, and a Shared folder (inside the Views folder).
The Account folder contains pages for registering and logging in to user accounts.
The Home folder is used for storing application pages like the home page and the about page.
The Shared folder is used to store views shared between controllers (master pages and layout pages).
Views 
We will edit the layout files in the next chapter of this tutorial.

The Scripts Folder

The Scripts folder stores the JavaScript files of the application.
By default Visual Web Developer fills this folder with standard MVC, Ajax, and jQuery files:
Scripts 
Note: The files named "modernizr" are JavaScript files used for supporting HTML5 and CSS3 features in the application.

23 Oct 2013

ASP.NET MVC - Internet Application

To learn ASP.NET MVC, we will Build an Internet Application
Part I: Creating the Application

What We Will Build

We will build an Internet application that supports adding, editing, deleting, and listing of information stored in a database.

What We Will Do

Visual Web Developer offers different templates for building web applications.
We will use Visual Web Developer to create an empty MVC Internet application with HTML5 markup.
When the empty Internet application is created, we will gradually add code to the application until it is fully finished. We will use C# as the programming language, and the newest Razor server code markup.
Along the way we will explain the content, the code, and all the components of the application.

Creating the Web Application

If you have Visual Web Developer installed, start Visual Web Developer and select New Project. Otherwise just read and learn.
New Project
In the New Project dialog box:
  • Open the Visual C# templates
  • Select the template ASP.NET MVC 3 Web Application
  • Set the project name to MvcDemo
  • Set the disk location to something like c:\w3schools_demo
  • Click OK
When the New Project Dialog Box opens:
  • Select the Internet Application template
  • Select the Razor Engine
  • Select HTML5 Markup
  • Click OK
Visual Studio Express will create a project much like this:
Mvc Explorer 
We will explore the content of the files and folders in the next chapter of this tutorial.

ASP.NET MVC Tutorial

The MVC Programming Model

MVC is one of three ASP.NET programming models.
MVC is a framework for building web applications using a MVC (Model View Controller) design:
  • The Model represents the application core (for instance a list of database records).
  • The View displays the data (the database records).
  • The Controller handles the input (to the database records).
The MVC model also provides full control over HTML, CSS, and JavaScript.

MVC
The MVC model defines web
applications with 3 logic layers:

The business layer (Model logic)
The display layer (View logic)
The input control (Controller logic)
The Model is the part of the application that handles the logic for the application data.
Often model objects retrieve data (and store data) from a database.
The View is the parts of the application that handles the display of the data.
Most often the views are created from the model data.
The Controller is the part of the application that handles user interaction.
Typically controllers read data from a view, control user input, and send input data to the model.
The MVC separation helps you manage complex applications, because you can focus on one aspect a time. For example, you can focus on the view without depending on the business logic. It also makes it easier to test an application.
The MVC separation also simplifies group development. Different developers can work on the view, the controller logic, and the business logic in parallel.

Web Forms vs MVC

The MVC programming model is a lighter alternative to traditional ASP.NET (Web Forms). It is a lightweight, highly testable framework, integrated with all existing ASP.NET features, such as Master Pages, Security, and Authentication.

Visual Studio Express 2012/2010

Visual Studio Express is a free version of Microsoft Visual Studio.
Visual Studio Express is a development tool tailor made for MVC (and Web Forms).
Visual Studio Express contains:
  • MVC and Web Forms
  • Drag-and-drop web controls and web components
  • A web server language (Razor using VB or C#)
  • A web server (IIS Express)
  • A database server (SQL Server Compact)
  • A full web development framework (ASP.NET)
If you install Visual Studio Express, you will get more benefits from this tutorial.
If you want to install Visual Studio Express, click on one of these links:
Visual Web Developer 2012 (If you have Windows 7 or Windows 8)
Visual Web Developer 2010 (If you have Windows Vista or XP)
lampAfter you have installed Visual Studio Express the first time, it pays to run the installation one more time, to install fixes and service packs. Just click on the link once more.

21 Oct 2013

Javascript Definitive Resources

If you want to list down your website, book or any other resource on this page then please contact at webmaster@tutorialspoint.com
  • ECMAScript - Official website for ECMAScript. Learn about the ECMAScript language and discover the ECMAScript community.
  • JavaScript - JavaScript at Wikipedia, the free encyclopedia
  • Mozilla Developer Center - The premier JavaScript sites. It has lot of tutorials and references You will really want to use this one.
  • JavaScript Technology - Your resource from Sun Microsystems for JavaScript editors, news, and blogs.
  • Rhino: JavaScript for Java - Rhino is an open-source implementation of JavaScript written entirely in Java.

Top JavaScript Frameworks:

  • Prototype - This holds the reference API documentation, replete with examples and crossreferences. You'll also find various tutorials and get to know Prototype Core members.
  • script.aculo.us - A complete set of reference API documentation, Installation Scripts.
  • DoJo - A complete set of reference API documentation, Installation Scripts.
  • Ext JS - A complete set of reference API documentation, Installation Scripts.
  • Rico - A complete set of reference API documentation, Installation Scripts.
  • Qooxdoo - qooxdoo is a comprehensive and innovative Ajax application framework.
  • ExtJs - Ext JS 4 JavaScript Framework for Rich Apps in Every Browser.
  • DHTMLX - DHTMLX is a JavaScript library that provides essential functionality for building cross-browser, Ajax-based user interfaces.

JavaScript Built-in Functions

Number Methods

The Number object contains only the default methods that are part of every object's definition.
MethodDescription
constructor()Returns the function that created this object's instance. By default this is the Number object.
toExponential()Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
toFixed()Formats a number with a specific number of digits to the right of the decimal.
toLocaleString()Returns a string value version of the current number in a format that may vary according to a browser's locale settings.
toPrecision()Defines how many total digits (including digits to the left and right of the decimal) to display of a number.
toString()Returns the string representation of the number's value.
valueOf()Returns the number's value.

Boolean Methods

Here is a list of each method and its description.
MethodDescription
toSource()Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
toString()Returns a string of either "true" or "false" depending upon the value of the object.
valueOf()Returns the primitive value of the Boolean object.

String Methods

Here is a list of each method and its description.
MethodDescription
charAt()Returns the character at the specified index.
charCodeAt()Returns a number indicating the Unicode value of the character at the given index.
concat()Combines the text of two strings and returns a new string.
indexOf()Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
lastIndexOf()Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
localeCompare()Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
length()Returns the length of the string.
match()Used to match a regular expression against a string.
replace()Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
search()Executes the search for a match between a regular expression and a specified string.
slice()Extracts a section of a string and returns a new string.
split()Splits a String object into an array of strings by separating the string into substrings.
substr()Returns the characters in a string beginning at the specified location through the specified number of characters.
substring()Returns the characters in a string between two indexes into the string.
toLocaleLowerCase()The characters within a string are converted to lower case while respecting the current locale.
toLocaleUpperCase()The characters within a string are converted to upper case while respecting the current locale.
toLowerCase()Returns the calling string value converted to lower case.
toString()Returns a string representing the specified object.
toUpperCase()Returns the calling string value converted to uppercase.
valueOf()Returns the primitive value of the specified object.

String HTML wrappers

Here is a list of each method which returns a copy of the string wrapped inside the appropriate HTML tag.
MethodDescription
anchor()Creates an HTML anchor that is used as a hypertext target.
big()Creates a string to be displayed in a big font as if it were in a <big> tag.
blink()Creates a string to blink as if it were in a <blink> tag.
bold()Creates a string to be displayed as bold as if it were in a <b> tag.
fixed()Causes a string to be displayed in fixed-pitch font as if it were in a <tt> tag
fontcolor()Causes a string to be displayed in the specified color as if it were in a <font color="color"> tag.
fontsize()Causes a string to be displayed in the specified font size as if it were in a <font size="size"> tag.
italics()Causes a string to be italic, as if it were in an <i> tag.
link()Creates an HTML hypertext link that requests another URL.
small()Causes a string to be displayed in a small font, as if it were in a <small> tag.
strike()Causes a string to be displayed as struck-out text, as if it were in a <strike> tag.
sub()Causes a string to be displayed as a subscript, as if it were in a <sub> tag
sup()Causes a string to be displayed as a superscript, as if it were in a <sup> tag

Array Methods

Here is a list of each method and its description.
MethodDescription
concat()Returns a new array comprised of this array joined with other array(s) and/or value(s).
every()Returns true if every element in this array satisfies the provided testing function.
filter()Creates a new array with all of the elements of this array for which the provided filtering function returns true.
forEach()Calls a function for each element in the array.
indexOf()Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
join()Joins all elements of an array into a string.
lastIndexOf()Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
map()Creates a new array with the results of calling a provided function on every element in this array.
pop()Removes the last element from an array and returns that element.
push()Adds one or more elements to the end of an array and returns the new length of the array.
reduce()Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
reduceRight()Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
reverse()Reverses the order of the elements of an array -- the first becomes the last, and the last becomes the first.
shift()Removes the first element from an array and returns that element.
slice()Extracts a section of an array and returns a new array.
some()Returns true if at least one element in this array satisfies the provided testing function.
toSource()Represents the source code of an object
sort()Sorts the elements of an array.
splice()Adds and/or removes elements from an array.
toString()Returns a string representing the array and its elements.
unshift()Adds one or more elements to the front of an array and returns the new length of the array.

Date Methods:

Here is a list of each method and its description.
MethodDescription
Date()Returns today's date and time
getDate()Returns the day of the month for the specified date according to local time.
getDay()Returns the day of the week for the specified date according to local time.
getFullYear()Returns the year of the specified date according to local time.
getHours()Returns the hour in the specified date according to local time.
getMilliseconds()Returns the milliseconds in the specified date according to local time.
getMinutes()Returns the minutes in the specified date according to local time.
getMonth()Returns the month in the specified date according to local time.
getSeconds()Returns the seconds in the specified date according to local time.
getTime()Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC.
getTimezoneOffset()Returns the time-zone offset in minutes for the current locale.
getUTCDate()Returns the day (date) of the month in the specified date according to universal time.
getUTCDay()Returns the day of the week in the specified date according to universal time.
getUTCFullYear()Returns the year in the specified date according to universal time.
getUTCHours()Returns the hours in the specified date according to universal time.
getUTCMilliseconds()Returns the milliseconds in the specified date according to universal time.
getUTCMinutes()Returns the minutes in the specified date according to universal time.
getUTCMonth()Returns the month in the specified date according to universal time.
getUTCSeconds()Returns the seconds in the specified date according to universal time.
getYear()Deprecated - Returns the year in the specified date according to local time. Use getFullYear instead.
setDate()Sets the day of the month for a specified date according to local time.
setFullYear()Sets the full year for a specified date according to local time.
setHours()Sets the hours for a specified date according to local time.
setMilliseconds()Sets the milliseconds for a specified date according to local time.
setMinutes()Sets the minutes for a specified date according to local time.
setMonth()Sets the month for a specified date according to local time.
setSeconds()Sets the seconds for a specified date according to local time.
setTime()Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.
setUTCDate()Sets the day of the month for a specified date according to universal time.
setUTCFullYear()Sets the full year for a specified date according to universal time.
setUTCHours()Sets the hour for a specified date according to universal time.
setUTCMilliseconds()Sets the milliseconds for a specified date according to universal time.
setUTCMinutes()Sets the minutes for a specified date according to universal time.
setUTCMonth()Sets the month for a specified date according to universal time.
setUTCSeconds()Sets the seconds for a specified date according to universal time.
setYear()Deprecated - Sets the year for a specified date according to local time. Use setFullYear instead.
toDateString()Returns the "date" portion of the Date as a human-readable string.
toGMTString()Deprecated - Converts a date to a string, using the Internet GMT conventions. Use toUTCString instead.
toLocaleDateString()Returns the "date" portion of the Date as a string, using the current locale's conventions.
toLocaleFormat()Converts a date to a string, using a format string.
toLocaleString()Converts a date to a string, using the current locale's conventions.
toLocaleTimeString()Returns the "time" portion of the Date as a string, using the current locale's conventions.
toSource()Returns a string representing the source for an equivalent Date object; you can use this value to create a new object.
toString()Returns a string representing the specified Date object.
toTimeString()Returns the "time" portion of the Date as a human-readable string.
toUTCString()Converts a date to a string, using the universal time convention.
valueOf()Returns the primitive value of a Date object.

Date Static Methods:

In addition to the many instance methods listed previously, the Date object also defines two static methods. These methods are invoked through the Date( ) constructor itself:
MethodDescription
Date.parse( )Parses a string representation of a date and time and returns the internal millisecond representation of that date.
Date.UTC( )Returns the millisecond representation of the specified UTC date and time.

Math Methods

Here is a list of each method and its description.
MethodDescription
abs()Returns the absolute value of a number.
acos()Returns the arccosine (in radians) of a number.
asin()Returns the arcsine (in radians) of a number.
atan()Returns the arctangent (in radians) of a number.
atan2()Returns the arctangent of the quotient of its arguments.
ceil()Returns the smallest integer greater than or equal to a number.
cos()Returns the cosine of a number.
exp()Returns EN, where N is the argument, and E is Euler's constant, the base of the natural logarithm.
floor()Returns the largest integer less than or equal to a number.
log()Returns the natural logarithm (base E) of a number.
max()Returns the largest of zero or more numbers.
min()Returns the smallest of zero or more numbers.
pow()Returns base to the exponent power, that is, base exponent.
random()Returns a pseudo-random number between 0 and 1.
round()Returns the value of a number rounded to the nearest integer.
sin()Returns the sine of a number.
sqrt()Returns the square root of a number.
tan()Returns the tangent of a number.
toSource()Returns the string "Math".

RegExp Methods:

Here is a list of each method and its description.
MethodDescription
exec()Executes a search for a match in its string parameter.
test()Tests for a match in its string parameter.
toSource()Returns an object literal representing the specified object; you can use this value to create a new object.
toString()Returns a string representing the specified object.