MVC

  • Home
  • HTML
    • Overview
    • Formatting
  • Java Script
    • Overview
    • Validation
  • CSS
    • Overview
  • Sql
    • Overview
    • SQL Select
    • SQL Command
    • Advance Query
    • SQL Create
    • Function
    • Function vs StoreProcedure
    • Stored Procedures
  • MVC
    • OverView
    • Evolution of MVC
    • Install VisualStudio-2015
    • Create First Application
  • LINQ
    • Introduction
  • Privacy Policy

Saturday, 8 July 2017

HTML Basic Important Points

  Unknown       13:37       HtmlOverview       No comments    

HTML Basic Document


In this Article Define Html Basics tag then you find easily that where we use. In this Define basics tag in follow example
Example
<html/>
<head/>
<title/>Demo Title</title>
</head/>
<body/>
Demo you can write code
</body>
</html>

Text Elements


In This Article Text Elements define all text type elements how you use like
Example
<html/>
<p>This is a paragraph Tag we denoted by p tag and write ant text in this paragraph</p>
<br> (line break). This tag is also denoted by br tag you want to break line and next line should come next and new line then use br tag.
<hr> (horizontal rule). This is denoted by hr tag if you wanna to show line after enter any headline and message then use hr tag it represent a line in horizontal manner.
<pre>This text is preformatted. This is Denoted by pre tag use for preformatted text </pre>

Logical Styles

Example
<em>This text is emphasized</em> <strong>This text is strong</strong> <code>This is some computer code</code>

Physical Styles

Example
<b>This text is bold.This is bold tag denoted by b tag if you wanna bold text and highlight tag then use this bold tag </b>
<i>This text is italic.This is denoted by i if you wanna text in italic then use this tag</i>

Links, Anchors, and Image Elements

Example
<a href="http://learningmvctutorial.blogspots.in/">This is a Link you can write any button and text and image any control give and set navigation path also</a>
A named anchor:
<a href="https://www.blogger.com/null" name="tips">Useful Tips Section</a>
<a href="https://www.blogger.com/blogger.g?blogID=1451780301140776859#tips">Jump to the Useful Tips Section</a>

Frames

Example
<frameset cols="25%,75%">
<frame src="page1.htm">
<frame src="page2.htm">
</frameset>

Forms

Example
<frame src="page2.htm">
<form action="http://www.google.com/" method="post/get">
<input type="text" name="lastname" value="Nixon" size="30" maxlength="50">
<input type="password">
<input type="checkbox" checked="checked">
<input type="radio" checked="checked">
<input type="submit">
<input type="reset">
<input type="hidden">
<select>
<option>Apples <option selected>Bananas <option>Cherries </select>
<textarea name="Comment" rows="60" cols="20"></textarea>
</form>

Entities


Example
&gt; is the same as <
&lt; is the same as >
&#169; is the same as ©

Other Elements

Example
<!-- This is a comment -->
<blockquote>
Text quoted from some source.
</blockquote>
<address>
Address 1
Address 2
City
</address>
Everywhere on the Web you will find pages that are formatted like newspaper pages using HTML columns.

Information Inside the Head Element


In this Articale describe How to give information inside the Head Element The elements inside the head element should not be displayed by a browser.
According to the HTML standard, only a few tags are legal inside the head section.
These are:<base>, <link>, <meta>, <title>
Look at the following illegal construct:
<head>
<p>This is some text</p>
</head>
In this case the browser has two options:
· Display the text because it is inside a paragraph element
· Hide the text because it is inside a head element
If you put an HTML element like <h1>or <p> inside a head element like this, most browsers will display it, even if it is illegal.
Should browsers forgive you for errors like this? We don't think so. Others do.

Head Tags


Tag Description
<head> Defines information about the document
<title> Defines the document title
<base> Defines a base URL for all the links on a page
<link> Defines a resource reference
<meta> Defines meta information
<!DOCTYPE> Defines the document type. This tag goes before the <html> start tag.

The Meta Element

In this Article Discuss about Meta element. The head element contains general information (meta information) about a document.
HTML also includes a meta element that goes inside the head element. The purpose of the meta element is to provide meta-information about the document.
Most often the meta element is used to provide information that is relevant to browsers or search engines like describing the content of your document.

Keywords for Search Engines

In this article we discuss about how to write keywords in meta tag so that we easily search.
Some search engines on the WWW will use the name and content attributes of the meta tag to index your pages through using Meta tag like in example.
This meta element defines a description of your page:
<meta name="description" content="Free Web tutorials on HTML, CSS, XML, and XHTML" />

This meta element defines keywords for your page:
<meta name="keywords" content="HTML, DHTML, CSS, XML, XHTML, JavaScript" />

The intention of the name and content attributes is to describe the content of a page.In this article discribe meta keyword and meta description both are mention whatever u want to give search on serach Engines.
However, since too many webmasters have used meta tags for spamming, like repeating keywords to give pages a higher ranking, some search engines have stopped using them entirely.

Unknown Meta Attributes


Sometimes you will see meta attributes that are unknown to you like this:
<meta name="security" content="low" />

Then you just have to accept that this is something unique to the site or to the author of the site, and that it has probably no relevance to you.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Thursday, 18 May 2017

CSS Selectors

  Unknown       11:26       CssOverview       No comments    

In this artical we define differntes types of selector see as above-

What is Selector?


Selector-CSS type selectors match elements by node name. Selector for a particular node name selects all elements of that type — that is, with that node name — in the document. andwe can define a selector is element which on we apply css propeties. like example

Syntex

<style type="text/css">>
Selector element { Define properties }
</style>

Example-

<style type="text/css">>
p{
background-color:blue;color:white;
}
</style>

In this tutorial we define selector like in example see.
Selector Description Example
div Define div and write css.Select all
<div> element
div {
padding:3px;
}
p Define p element and write css.Select all
<p> element
p {
padding:3px;
}
h1 Define h1 element and write css.Select all
<h1> element.Basically we use heading style 1,h2,h3,h4,h5,h6.Maintain this order like- h1>h2>h3>h4>h5>h6 In this h1 is very large size of font and text and h6 is very small.
h1 {
color:red;
}
.class Define class with .(dot)symbol and apply css class and access class name with .(ClassName) .name {
padding:3px; color:blue;
}
.Id Define class with # symbol and apply css class and access class name with #(ClassName) #name {
padding:3px; color:blue;
}
* * (Use this symbol select all element only use * effected all element) .name {
padding:3px; color:blue;
}
div, p Selects all <div> elements and all <p> elements.Apply css propert effected all elements of both<div>& <p> div,p {
padding:3px; color:blue;
}
div p Selects all
elements inside <div> elements.Apply css property effected all elements of both <div>& <p>
div p {
padding:3px; color:blue;
}
div > p Selects all <p> elements where the parent is a <div> element where effected css properties div > p {
padding:3px; color:blue;
}
div + p Selects all <p> elements that are placed immediately after <div> elements. Whereis effected css properties div > p {
padding:3px; color:blue;
}
[title~=fruit] Selects all elements with a title attribute containing the word "fruit" where apply css properties which is declared [title~=fruit]{
padding:3px; color:blue;
}
p~ul Selects every <ul> element that are preceded by a <p> element. p~ul{
padding:3px; color:blue;
}
a[href^="https"] Selects every <a> element whose href attribute value begins with "https" a[href^="https"]{
padding:3px; color:blue;
}
a[href$=".pdf"] Selects every <a> element whose href attribute value ends with ".pdf" a[href$=".pdf"]{
padding:3px; color:blue;
}
a:active Selects the active link of a tag and easly apply css property a:active{
padding:3px; color:blue;
}
p::after Insert something after the content of each <p> element and we can easly write css property p::after{
padding:3px; color:blue;
}
p::before Insert something before the content of each <p> element p::before{
padding:3px; color:blue;
}
input:checked Selects every checked <input> element input:checked{
padding:3px; color:blue;
}
input:disabled Selects every disabled <input> element input:disabled{
padding:3px; color:blue;
}
p:empty Selects every <p> element that has no children (including text nodes) p:empty{
padding:3px; color:blue;
}
input:enabled Selects every enabled <input> element input:enabled{
padding:3px; color:blue;
}
p:first-child Selects every <p> element that is the first child of its parent p:first-child{
padding:3px; color:blue;
}
p::first-letter Selects the first letter of every <p> element.You can apply css properties and effected only first letter of every <p>elements. p::first-letter{
padding:3px; color:blue;
}
p::first-letter Selects every <p> element that is the first child of its parent p:first-child{
padding:3px; color:blue;
}
p::first-line Selects the first line of every <p> element.You can appy css property and effected on <p>tag first line. p::first-line{
padding:3px; color:blue;
}
p:last-child Selects every <p> element that is the last child of its parent.You can appy css property and effected. p:last-child{
padding:3px; color:blue;
}
a:hover Selects links on mouse over.You can give css property easly a:hover{
padding:3px; color:blue;
}
input:focus Selects the input element which has focus.You can apply css style easly want focus then. input:focus{
padding:3px; color:blue;
}
input:invalid Selects all input elements with an invalid value. input:invalid{
padding:3px; color:blue;
}
a:link Selects all unvisited links. a:link{
padding:3px; color:blue;
}
:not(p) Selects every element that is not include <p> element :not(p){
padding:3px; color:blue;
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 13 May 2017

Types of CSS

  Unknown       22:22       CssOverview       No comments    

In this Tutorial Describe Types of CSS Basically we define 3 types of CSS see above-

  • Inline CSS
  • Internal (embedded) CSS
  • External CSS

Inline CSS -
In This CSS we add inline style.
Inline styles are styles that are written directly in the tag like div,textbox button etc. Inline styles affect only the tag they are applied to and not effect other tag untill unless not match same name and id of tag other wise apply both if match 2 tag's same name then.
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. See in Above Example-
Example Inline CSS
<!DOCTYPE html>
<html>
<body>
<div style="background-color:wheat;width:200px;height:50px;border:1px solid" >
</div>
</body>
</html>
Output-

Internal (embedded) CSS

Embeddded style are written on same page in head section we define all css properties and that is reflected only this page where we define internal css.
An internal style sheet should be used when a single document has a unique style. You
define internal styles in the head section by using the <stye type="text/css"> Select : Property
</style>
Example Internal CSS
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.inlinecss {
background-color:wheat;
width:300px;
height: 50px;
border:1px solid;
}
</style>

</head>
<body>
<div class="inlinecss">
</div>
</body>
</html>
Output-

The browser will now read the style definitions, and format the document according to it.
Note: A browser normally ignores unknown tags. This means that an old browser that
does not support styles, will ignore the <style> tag, but the content of the <style> tag will
be displayed on the page. It is possible to prevent an old browser from displaying the
content by hiding it in the HTML comment element:
<head>
<style type="text/css">
<!--
hr {color: sienna}
p {margin-left: 20px}
body {background-image: url("images/back40.gif")}
-->
</style>
</head>

External CSS

External styles are styles that are written in a separate document and then attached to various Web documents. External style sheets can affect any document they are attached to.We add external style sheet then attach on each page you want to attach and reflect those page. Use external sheet then no need internal and inline css and want common for whole site. This is easy to maintain for website.
An external style sheet is ideal when the style is applied to many pages. With an external
style sheet, you can change the look of an entire Web site by changing one file. Each page

Example
<link rel="stylesheet" type="text/css" href="styles.css" />
Note-> In this Styles.css file we write all styles in styles.css file. Give link on page where we want.

The browser will read the style definitions from the file styles.css, and format the
document according to it.You can write css style whatever you write all styles in this file.
An external style sheet can be written in any text editor. The file should not contain any
html tags. Your style sheet should be saved with a .css extension. An example of a style
sheet file is shown below:

hr {color: sienna}
p {margin-left: 20px}
body {background-color:blue;}

Note - Do NOT leave spaces between the property value and the units! If you use "marginleft:
20 px" instead of "margin-left: 20px" it will only work properly in IE6 but it will not
work in Mozilla/Firefox or Netscape.

Multiple Style Sheets 

If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet.
For example, an external style sheet has these properties for the h3 selector:
 h3 {
color: red; text-align: left; font-size: 8pt;
}
 And an internal style sheet has these properties for the h3 selector:
 h3
{
text-align: right; font-size: 20pt;
}
If the page with the internal style sheet also links to the external style sheet the properties for h3 will be: 
color: red; text-align: right; font-size: 20pt
The color is inherited from the external style sheet and the text-alignment and the fontsize is replaced by the internal style sheet.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 6 May 2017

Ordered and Unordered list in Html

  Unknown       10:45       HtmlOverview       No comments    

Types of list in html


We define any defination and content in list form then we give order and unorder. Basically 3 types of list use in-
Unorder list
Order list
Defination list

Unordered list


An unordered The list items are marked with bullets (typically small black circles). An unordered list is a list of items. This list starts with the <ul> tag. Every list item starts with the <li> tag.
Example
<!DOCTYPE html>
<html>
<body>
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</u1>
</body>
</html>
Output-
.List 1
.List 2
.List 3

Ordered list


An ordered list is also a list of items. The list items are Started with numbers. This ordered list starts with the <ol> tag. Every list item starts with the <li> tag.
Example
<!DOCTYPE html>
<html>
<body>
<ol>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</o1>
</body>
</html>

Output-
1. List 1
2. List 2
3. List 3

Definition Lists


A definition list is a list of items (terms), with a description of every item (term).It is not a list of items.
A definition list starts with a <dl> tag (definition list).
Every term starts with a <dt> tag (definition term).
Each description starts with a <dd> tag (definition description).
Example
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>List 1</dt>
<dd>This is List1</dd>
<dt>List 2</dt>
<dd>This is List2</dd>
<dt>List 3</dt>
<dd>This is List3</dd>
</d1>
</body>
</html>

Output-
List 1
This is List1
List 2
This is List2
List 3
This is List3

Forms


HTML Forms are used to select different kinds of user input we describe many input.
Html formis defined with <form> tag
In this tag you can use many input tag like text box, drop down and radio button etc. Use form tag and write any content in between form tag then only show content rather then form tag because form tag is not visible user only hold content and input type.
Ex.
   <form>
         Write content
   </form>

Write Input element

Html language support many input element like-

Text Field


Text fields are used when you want the user to type Word, numbers, any content etc. in a form.Then use this text field like-
Example
<!DOCTYPE html>
<html>
<body>
<form >
Name:
<input type="text" id="txtname" name="name" /> </form >
</body>
</html>

Output-

  Name:


Radio Buttons


Radio Buttons are used when you want the user to select one of choices. It's called single selection.
Example
<!DOCTYPE html>
<html>
<body>
<form >
<input type="radio" name="sex" value="male" /> Male
<input type="radio" name="sex" value="Female" /> FeMale
</form >

</body>
</html>
Output- Male Female

Checkboxes


Use checkbox for multiple selection. Checkboxes are used when you want the user to select one or more options of choices.
Example
<!DOCTYPE html>
<html>
<body>
<form >
<input type="checkbox" name="Hobby" value="Dancing" /> Dancing
<input type="checkbox" name="Hobby" value="Singing" /> Singing
<input type="checkbox" name="Hobby" value="Cooking" /> Cooking
<input type="checkbox" name="Hobby" value="Gardning" /> Gardning
</form >

</body>
</html>
Output-Dancing SingingcookingGardening

Drop Down

It is use single select of multi list.In his drop down list we define many options value in the list.
Example
<!DOCTYPE html>
<html>
<body>
<form >
<select name="hobbies"> <option value="0">Select </option> <option value="1">Dancing </option> <option value="2">Singing </option> <option value="3">Cycling </option> </select< </form >

</body>
</html>
Output-
Example
<!DOCTYPE html>
<html>
<body>
<form >
<input type="checkbox" name="Hobby" value="Dancing" /> Dancing
<input type="checkbox" name="Hobby" value="Singing" /> Singing
<input type="checkbox" name="Hobby" value="Cooking" /> Cooking
<input type="checkbox" name="Hobby" value="Gardning" /> Gardning
</form >

</body>
</html>
 Output-
    

Label


Label = Label is also a control.It is used to dispaly any content.
It is denoted by <label>
<label for="lable1"> Label </label>
Output

Textarea

This is another control it is input type control and multiline textbox . This field is editable and denoted this tag
<textarea >

Button


Button control in html we use button for fire a event then use and save data on click this button then we use button.
<input type="button" value="button" />
<input type="submit" value="submit" />
Output-
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Sunday, 30 April 2017

Fetch Unique random Record in sql server

  Unknown       10:15       Select       No comments    

Fetch Unique random Record in sql server


In This Artical You can easily fetch unique and random record And you get each time unique record if you execute this query every time you fetch unique and random record using Newid() function.
Follow some steps-

  • Step 1 - Firstly Create Data base and create Table See in Example.
  • Step 2 - Create table after that insert some record and select records.
  • Step 3 - Now get some random and unique record than use new id function() ,this function fetch                       random record each time

Example
Step 1-
CREATE TABLE Tbl_Customer
(
      ID INT PRIMARY KEY IDENTITY(1,1),
      Name NVARCHAR(200),
       Salary DECIMAL(18,2)
)
Step 2-
Insert Record -
INSERT INTO Tbl_Customer(Name,Salary)VALUES('RAJ',25000)
Insert multiple records and select with select query
Select * from Tbl_Customer
Step 3-
SELECT TOP 1 * FROM Tbl_Customer ORDER BY NEWID()
Fetch unique and random record then use this query-
if you execute this query then got one record and next time execute then got different record so you can easily find unique and random records using NewId() function.


The key here is the NEWID function, which generates a globally unique identifier (GUID) in memory for each row.By definition, the GUID is unique and fairly random; so, when you sort by that GUID with the ORDER BY clause, you get a random ordering of the rows in the table. So finaly we get Unique and Random rows by using this query. We use Top 1 its use to only Top 1 result in table.

SQL Select Top

In this artical filtring records according SELECT TOP clause. The SELECT TOP clause is used to specify the number of records to return. The SELECT TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance. You can select top 10 percent also and filter record according percents.
Example
Create table tbl_Employee in SQL Server.
CREATE TABLE Tbl_Employee
(
Id int primary key identity(1,1),
Name nvarchar(50),
Salary decimal(18,2)
)

Insert Records in table with Insert Query like.Write insert query and execute (f5).
INSERT INTO Tbl_Employee VALUES('JEET',30000)
Inserted record and after that Select table and show data.
Example
SELECT * FROM Tbl_Employee
Output

Now Select table and table return all rows you can Apply select Top then Write query select top like
Example Select Top
Syntex
SELECT TOP number|percent ColumnName(s) FROM TableName
SELECT Top 5 * FROM Tbl_Employee
Output
Note- In this example Select Top 5 then show only 5 records and you can Write top6 ,7,8...etc and get result according top numbers. Select Top number you want to give percent then write percent also like. In this example select top 50 percent then record give just half of all records.It is filter According percentage.
Example Select Top
Syntex
SELECT Top 50 PERCENT * FROM Tbl_Employee

Rank Given In Table

Rank Given in Table in SQL Server
If We Want to Give Indviual Rank And Same Rank to Same data Then Use

Use Of  ROW_NUMBER() Function 
1.This function will assign a unique id to each row returned from the query.
2.RANK gives you the ranking within your ordered partition. Ties are assigned the same rank, with the next ranking(s) skipped. So, if you have 3 items at rank 2, the next rank listed would be ranked 5.

DENSE_RANK()
Trivially, DENSE_RANK() is a rank with no gaps, i.e. it is “dense”. We can write:

Code
Create table-
CREATE TABLE Tbl_CityMaster1
(
Id INT PRIMARY KEY IDENTITY,
CityName nvarchar(20),
C_Id int
)
Data Insertd Then OutPut
OutPut-
Id  CityName   C_Id
1    Allahabad    1
2    Allahabad   1
3    Allahabad    1
4    Patna        1
5    Patna        2
6    Patna        3
7    Varanasi    3
8    Varanasi    3
9    Varanasi    3
10    Varanasi    3

Give Rank 

Query-
SELECT
    Id,CityName,[C_id],
    Row_index = ROW_NUMBER() OVER(PARTITION BY [C_Id] ORDER BY [C_Id]),
    SameRank = DENSE_RANK() OVER (ORDER BY [C_Id])
FROM Tbl_CityMaster

OutPut

Id CityName  C_Id RowNo SameRank
1    Allahabad     1    1     1
2    Allahabad     1    2     1
3    Allahabad     1    3     1
4    Patna             1    2     2
5    Patna             2    2     2
6    Patna             3    2     2
7    Varanasi        3    1     3
8    Varanasi        3    2     3
9    Varanasi        3    3     3
10    Varanasi      3    4     3


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Operator in JavaScript

  Unknown       04:25       javascriptOverview       No comments    

What is an operator?


JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator:
operand1 operator operand2
For example, 3+4 or x*y.

A unary operator requires a single operand, either before or after the operator:
operator operand
or
operand operator
For example, x++ or ++x.
Let us take a simple expression 5 + 5 is equal to 10. Here 5 and 5 are called operands and ‘+’ is called the operator.
JavaScript supports the following types of operators.

  • Arithmetic Operators
  • Comparision Operators
  • Logical (or Relational) Operators
  • Assignment Operators
  • String Operators
  • Conditional (or ternary) Operators


Using this operator we easly add,subtract,multiply,divide etc like see in example. Operator Description Example Result.

Arithmetic Operators

Operator Description Example Expression Result
+ Addition x=2
y=2
x+y 4
- Subtraction x=5, y=3 x-y 2
* Multiplication x=5,y=5 x*y 25
/ Division x=15,y=5 x/y 3
% Modulus (division remainder) x=5,y=2 x%y 1
++ Increment x=5 x++ 6
-- Decrement x=5 x-- 4

Comparison Operators

Operator Description Example
== is equal to5==8 returns false
=== is equal to (checks for both value and type) x=5,y="5"
x==y returns true
x===y returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
>= is Greter than equal 5 >=8 returns false
< is Less than 5 <8 returns true
<= is Less than equal 5 <=8 returns true

Logical Operators

Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true
|| or x=6
y=3
x==5 || y==5) returns false
! Not x=5
y=2
!(x==y) returns true

Assignment Operators

In this opertor You can assign value in variable in javascript
Syntex -    var x= value;
Example - var x = 5;
=  this is Assign Operator you can assign any value using this operator. In this example assign 5 value in x variable and use this

String Operators

A string is most often text, for example "Hello World!". To stick two or more string variables together, use the + operator.
txt1="How a very";
txt2="nice flower
txt3=txt1+txt2;

The variable txt3 now contains "How a verynice flower!". To add a space between two string variables, insert a space into the expression, OR in one of the strings.
txt1="How a very";
txt2="nice flower!";
txt3=txt1+" "+txt2;
or
txt1="How a very ";
txt2="nice flower!";
txt3=txt1+txt2;

The variable txt3 now contains "How a very nice flower!".

Conditional Operators


JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.
Syntax
variablename=(condition)?value1:value2
Example
greeting=(visitor=="PRES")?"Dear President ":"Dear ";
If the variable visitor is equal to PRES, then put the string "Dear President " in the variable
named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 22 April 2017

Conditional Statements in JavaScript

  Unknown       11:39       javascriptOverview       No comments    

Conditional Statements

In This Tutorial You want to perform different actions for different situvation.
In JavaScript we have the following conditional statements:

  • if statement .
  • if-else statement .
  • if...else if....else statement.
  • switch statement.


  • if statement - If statement if you want to execute some code only if a specified condition is true

Syntax

  if (condition)
  {
          Write if condition which is true
  }

Example
<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript">
    //If Age is grater than 18 then eligible for voting
     var age= 20;
       if(age>18) {
            document.write("Age Is Valid For Vote")
          }
 </script>
</head>
</html>


  • if...else statement -  This statement if you want to execute some code if the condition is true and another code if the condition is false

Syntax

if (condition)
  {
    Write True condition.
  }
else
 {
   Write False condition.
 }

Example
<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript">
    //If Age is grater than 18 then eligable for voting
    var age= 15;
    if(age>18) {
         document.write("Age Is Valid For Vote")
        }
    else
        document.write("Age Is Not Valid For Vote")
  </script>
</head>
</html>


  • if...else if....else statement - Use this statement if you want to select one of many blocks of code to be executed

Syntax

if (condition1)
{
   code to be executed if condition1 is true
}
else if (condition2)
{
   code to be executed if condition2 is true
}
else if (condition3)
{
   code to be executed if condition3 is true
}
else
{
   code to be executed if condition1 and condition2 and condition3 are not true
}

Example
<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript">
      var d = new Date()
      var time = d.getHours()
       if (time<10) {
            document.write("Good morning");
          }
       else if (time>10 && time)<16 br=""> {
           document.write("Good day");
         }
      else if (time>16 && time)<19 br=""> {
           document.write("Good Evening");
        }
      else if (time>19 && time)<24 br=""> {
          document.write("Good Night");
        }
     else
       {
         document.write("Hello World!");
        }
  </script>
</head>
</html>


  • switch statement - Switch statement if you want to select one of many blocks of code to be executed

Syntax

switch(n)
{
  case 1:
    execute code case 1
    break;
  case 2:
    execute code case 2
    break;
  default:
    code to be executed if n is
    different from case 1 and 2
}
This is how it works: First we have a single expression n (most often a variable), that is evaluated once. The value of the expression is then compared with the values for each case in the structure. If there is a match, the block of code associated with that case is executed. Use break to prevent the code from running into the next case automatically.

Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
//You will receive a different greeting based
//on what day it is. Note that Sunday=0,
//Monday=1, Tuesday=2, etc.
   var d=new Date();
   theDay=d.getDay();
   switch (theDay)
    {
        case 5:
           document.write("Day is Friday");
           break;
        case 6:
            document.write("Day is Saturday");
            break;
        case 0:
             document.write("Day is Sunday");
             break;
        default:
              document.write("I'm looking forward to this weekend!");
     }
</script>
</head>
</html>

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Newer Posts Older Posts Home

learningmvctutorial

Popular Posts

  • Overview
      SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
  • Overview of HTML
    What is HTML? First developed by Tim Berners-Lee in 1990 . HTML is used to create electronic documents (called pages) that are displ...
  • Difference Between function v/s store procedure
    Definition  of Store Procedure In a database management system (DBMS), a  stored procedure  is a set of Structured Query Language (SQL...
  • SQL Select
    The SQL SELECT Statement The SELECT statement is used to select data from a database. SQL SELECT Syntax SELECT column_name , column_n...
  • What is LINQ
    LINQ  (Language Integrated Query) is a Microsoft programming model and methodology that essentially adds formal query capabilities into Mic...
  • What is Function in Sql Server
    A function is a block of code that has a name and it has a property that it is reusable. We use function in store Procedure and queries in...
  • Create Duplicate Table of existing table in SQL Server
    In This Tutorial we create table and want to same structure and same data then We create new table with data type after that  insert in ta...
  • About Javascript
    What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
  • Operator in JavaScript
    What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
  • Open Application in MVC
    We want to create application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer and  I...

Blog Archive

  • ▼  2017 ( 35 )
    • ▼  November ( 1 )
      • Date Formate in Sql
    • ►  October ( 2 )
    • ►  September ( 4 )
    • ►  August ( 1 )
    • ►  July ( 1 )
    • ►  May ( 3 )
    • ►  April ( 7 )
    • ►  March ( 13 )
    • ►  February ( 3 )
Powered by Blogger.

Categories

  • AdvanceQuery
  • CreateApplication
  • CreateDb
  • CssOverview
  • Evolution
  • Formatting
  • Function
  • FunctionVSSp
  • HtmlOverview
  • InstallVisualStudio
  • Introduction
  • javascriptOverview
  • JsValidation
  • Mvc-vs-Asp.Net
  • OverView
  • Select
  • SqlCommand
  • SQLOverview
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © MVC | Powered by Blogger
Design by Vibha Acharya