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

Wednesday, 15 November 2017

Date Formate in Sql

  Unknown       07:16       Function       No comments    

Show Current Date-

  Show Current Date Then Use-
 
  SELECT GETDATE()  AS CurrentDate
OutPut-
           2016-06-08 12:11:00.083

 More Format In Date Then Use-
 
Ex. 1:
 SELECT CONVERT(varchar(20),GETDATE(),100)  AS CurrentDate
OutPut-
           Jun  8 2016 12:13PM 

 Ex.2:
 SELECT CONVERT(varchar(20),GETDATE(),101)  AS CurrentDate
OutPut
       06/08/2016

Ex.3:
 SELECT CONVERT(varchar(20),GETDATE(),102)  AS CurrentDate
OutPut
      2016.06.08

Ex.4:
 SELECT CONVERT(varchar(20),GETDATE(),103)  AS CurrentDate 
OutPut
     08/06/2016

Ex.5 

  • CONVERT(varchar(20),GETDATE(),104)  =  08.06.2016.
  • CONVERT(varchar(20),GETDATE(),105 )=  08-06-2016
  • CONVERT(varchar(20),GETDATE(),106) =  08 Jun 2016
  • CONVERT(varchar(20),GETDATE(),107) =  Jun 08, 2016
  • CONVERT(varchar(20),GETDATE(),108) =  12:24:08
  • CONVERT(varchar(20),GETDATE(),109) =  Jun 08, 2016
  • CONVERT(varchar(20),GETDATE(),110) =  06-08-2016
  • CONVERT(varchar(20),GETDATE(),111) = 2016/06/08
  • CONVERT(varchar(20),GETDATE(),112) = 20160608
  • CONVERT(varchar(20),GETDATE(),113) = 08 Jun 2016 12:26:08

ONLY FATCH TIME IN DATE THEN USE

EX.1

 SELECT (LTRIM( RIGHT(CONVERT(varchar(20),GETDATE(),100),7))) as  CURRENTTime
 OutPut
     12:28PM
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Monday, 16 October 2017

Except vs NotNull in Sql Server

  Unknown       09:52       No comments    

EXCEPT & INTERSECT command in SQL Server


EXCEPT


In this Article EXCEPT command use to commind two queries and find dinctinct records. EXCEPT returns any left query values which are not exist in right query. You can use Except command and easily find distinct value of one table when you want filter values.

SYNTAX


The Syntax of EXCEPT command
SELECT ColumnName1,ColumnName2,....ColumnNameN FROM TableName1
EXCEPT
SELECT ColumnName1,ColumnName2,....ColumnNameN FROM TableName2

Note - You Should know about same number of column in all Queries Example of Except Command in SQL server you can more clear in example
Example
. SELECT * from Table1
EXCEPT
select * from Table2
Note -You can write this query and execute (f5) after that You got result 'name which is ditinct and not match in right table.'
Result - You can see output record.
Image

Intersect


In this Article Intersect command use to commind two queries and find common records. You can use Intersect command and easily find common values.

SYNTAX


The Syntax of Intersect command
SELECT ColumnName1,ColumnName2,....ColumnNameN FROM TableName1
Intersect
SELECT ColumnName1,ColumnName2,....ColumnNameN FROM TableName2

Note - You Should know about same number of column in all Queries Example of Intersect Command in SQL server you can more clear in example
Example
SELECT * from Table1
INTERSECT
select * from Table2
Note -You can write this query and execute (f5) after that You find result 'name which is common in both table.'
Result - You can see output record.
Image

What is a NULL Value in Sql?


In this tutorial we describe that NULL value is a field with does not have any value. You can Insrt a new record and update without any value then field have 'no value' and field will be saved with a NULL value
Note - NULL value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation.

What is Not NULL Value in Sql?


In this tutorial we describe that Not NULL value is a field which have value ,doesn't null value.

Difference between Except vs Not In

Except


EXCEPT filters the DISTINCT values from the left-hand table that do not appear in the right-hand table. It's essentially the same as doing a NOT EXISTS with a DISTINCT clause.
It also expects the two tables (or subset of columns from the tables) to have the same number of columns in the left and right hand side of the query

NOT IN

NOT IN does not filter for DISTINCT values and returns all values from the left-hand table that do not appear in the right-hand table.
NOT IN requires you compare a single column from one table with a single column from another table or subquery.
For example, if your subquery was to return multiple columns:
SELECT * FROM TableA AS nc WHERE ID NOT IN (SELECT ID, Name FROM TableB AS ec)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Sunday, 1 October 2017

Sql Commands

  Unknown       05:11       SqlCommand       No comments    

Sql Select Query

SQL Select all data from Table as you can see in my previous Article
http://learningmvctutorial.blogspot.in/2017/03/sql-select.html

Insert Query

In SQL Server you can use Insert data in table help of Insert Query
Syntax
INSERT INTO TableName(ColumnName1,ColumnName2,ColumnName3) VALUES(@value1,@value2,@value3)

Note- In this Insert Query those Column you want to insert in table then define column name and give there values according field data type.
This is Syntax and you can see example so more clear about this query
Example
INSERT INTO Tbl_Employee(Name, Salary,City) VALUES ('Radhe',40000,'Jaipur')
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)"
Result - You can run select query and see output record.

Update Query

In SQL Server you can use update record in table help of Update Query
Syntax
UPDATE TableName SET ColumnName1=@value1,ColumnName2=@value2 WHERE ColumnName Condition OPERATORE

Note- In this Update Query those existing Column you want to update in the table then define column name and set values according field data type if you want to give where condition then give if you not give where condition then reflect all this full of table.
This is Syntax and you can see example so more clear about this query
Example
UPDATE Tbl_Employee SET Name = 'Sita', Salary=12000 WHERE Id=4
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)"
Result - You can run select query and see output record.

Delete Query

In SQL Server Delete query is used to delete record in SQL server.You can see example
Syntax
DELETE FROM TableName WHERE ColumnName Condition operator

Note- In this Delete Query those record you want to delete from table then use this delete query if you want to delete record according condition then use 'where Clause' and use which record you want to delete use this condition , if you not give where condition then reflect all this full of table.
This is Syntax and you can see example so more clear about this query
Example
DELETE FROM Tbl_Employee SET Name = 'Sita', Salary=12000 WHERE Id=4
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)"
Result - You can run select query and see output record.

SQL In Operator

In SQL Server In Operator use to multiple value use in where clause.You  can use In operator and apply more than 1 values in where clause and get result according match  values you can see In operator example
Syntax
SELECT ColumnName FROM TableName WHERE ColumnName IN (value1,value2,...)

Note- Use this syntax find easily match record using In operator, Basically use In Sytax and give vales in where clause whatever you want to match.
This is Syntax and you can see example so more clear about this query
Example
SELECT Name FROM Tbl_Employee WHERE City IN ('Chittorgarh','Jaipur')
Note - You can write this query and Run f5 then You find result employee name those belongs city is Chittorgarh and Jaipur"
Result - You can run select query and see output record.

SQL Between Operator

In SQL Server Between Operator is used to select values within a range Commonly use for rang. You can see example
Syntax
SELECT ColumnName FROM TableName WHERE ColumnName Between value1 and value2

Note- Use this Syntax find record within range using Between operator, Basically use In syntax and give vales in where clause whatever you want to define rang.
This is Syntax and you can see example so more clear about this query
Example
SELECT Name FROM Tbl_Employee WHERE Salary Between 1000 and 30000
Note -You can write this query and Run f5 then You find result employee name those Salary between 1000 to 30000"
Result - You can run select query and see output record.

ALTER  Commands
The SQL ALTER TABLE command is used to add, delete or modify columns in an existing table.
You would also use ALTER TABLE command to add and drop various constraints on a an existing table.
Add new column in existing table through Alter Command
ALTER TABLE table_name ADD column_name datatype;
Drop column in existing table through Alter Command
ALTER TABLE table_name DROP COLUMN column_name;
Change The Data Type of  column in existing table
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
Add  NOT NULL constraint to a column
ALTER TABLE table_name MODIFY column_name datatype NOT NULL;
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Sunday, 24 September 2017

INSERT INTO statement in SQL

  Unknown       08:57       AdvanceQuery       No comments    

INSERT INTO SELECT Statement


In this article describe about Insert data one table to existing table The INSERT INTO SELECT statement selects data from one table and inserts it into an existing table.
Example
In this article Firstly create 2 tables like - tbl_1,tbl_2 and insert some values in tbl_1 Using 'INSERT INTO' Statement data Insert into tbl_2 table , you will find all records in tbl_2 table
Create Table

Create table tbl_1
(
Id int,
name nvarchar(10)
)


Note -
Table tbl_1 created with two field and same for tbl_2 with same field and datatype, name may be different but datatype same

Above Example Created Table tbl_1 after that Use Insert into Statement


Syntex
Note -
INSERT INTO [TableName]
SELECT * FROM [TableName]

You also see example then you can better understand

Example
INSERT INTO tbl_2
SELECT * FROM tbl_1


Note -
In this example Tbl_2 inserted all record which are in tbl_1, You can see above using select statement
SELECT * FROM tbl_2

SELECT INTO STATEMENT


you can want to make replica of table then use select into
select * into tbl_2 from tbl_1 In this no need create table ,following example we can't create table tbl_2 only create tbl_1 and just make replica so table and data same copy in replica of table this is explain in my previous article
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Sql Like Operator

  Unknown       08:18       Select       No comments    

The SQL LIKE Operator


In this Article describe Like Operator. The SQL LIKE clause is used to compare a value to similar values using wildcard operators. The LIKE operator is used to search for a specified pattern 'start letter and end letter and Contain letter/words' in a column. There are two wildcards used in LIKE operator.
1.(%) Percent Sign.
2.(_) Under Score Sign.
Percent sign (%) - This sign represents zero, one or multiple characters. Under Score ( _ ) - This sign represents a single number or character And use in Combination.
Syntax
SELECT ColumnName FROM TableName WHERE ColumnName LIKE pattern

We use like operator many types in Sql query.-

1.Start with letter
SELECT * FROM Tbl_Employee WHERE name LIKE 'M%'


Note - In this example those name start with 'M' letter, You can get result using like Operator

2. End with letter
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE '%M'
Note - In this example those name End with 'M' letter, You can get All result those name end with 'M' letter using like Operator

3.Contain letter in word
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE '%M%'
in any position. Note - In this example those name contain 'M' letter in word at any position, You can get All result those name contain 'M' letter using like Operator

4.Contain in letter in word
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE '%M%'
Note - In this example those name End with 'M' letter, You can get All result thoses name end with 'M' letter using like Operator

SQL _ Wildcard

1. Start letter with ( _ )
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE '_e'
Note - In this example those name start with '_' means any charter but second place character is e , You can get All result those name have second position contain 'e' .

2. End letter with (_)
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE 'ra_'
Notes- In this example use like operator with _ Wildcard search result with start with ra and end with any letter.

3. Middle word have wildcard
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE 'J_c_'
Notes-In this example use like operator with _ Wildcard. The following SQL statement selects all Employee with a City starting with "J", followed by any character, followed by "c", followed by any character. You can get this type of result easily.

SQL [charlist] Wildcard


This type of pattern use where you want to fetch some records those name start with some specific character
Example-
SELECT * FROM Tbl_Employee WHERE name LIKE '[rjm]%';
Notes - In this example use like operator with charlist. The following SQL statement selects those Employee who's name starting with "r","j" & "m"apply this pattern you can find output easily.
The following SQL statement selects all employee's name start with "r", "j", or "m"
You can use different type of like see above example -
SELECT * FROM Tbl_Employee WHERE name LIKE '[a-z]%'; Note - In this example select all employee those name consist and start with 'a' to 'z' range you can get all record. if you want the you change rang also like you give '[a-m]%' use this pattern then only find within range all records.

You can use same pattern not start with character in this following example see above-
SELECT * FROM Tbl_Employee WHERE name LIKE '[!rjm]%'; Note - In this example select all employee those name not start with "r", "j", or "m" .Using this pattern you can get all records.

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

Thursday, 21 September 2017

Html Formatting

  Unknown       11:12       Formatting       No comments    

Text Editing

You can edit text easly in html using many predefine tags. HTML also defines special elements and tags for defining text with a special meaning. Using those type of Formatting elements like-
  •  <b> - Use this element to bold text
  • <strong> - This is also same bold tag but give Important text
  • <i> - Use this for Italic text 
  • <em> - This is use for Emphasized text
  • <mark> - This is use Marked text
  • <small> - This is use Small text
  • <del> - This is use Deleted text
  • <ins> - This is use Inserted text
  • <sub> - This is use Subscript text
  • <sup> - This is use Superscript text
Html <b> Element Example -
Example
<b> This is example of bold tag < /b>
Note -you can write any text within <b> tag
Result - This is example of bold tag
Html <strong> Element  Example-
Example
<strong> This is example of strong tag < /strong>
Note -you can write any text within <strong> tag
Result - This is example of strong tag
Html <i> Element Example
Example
<i> This is example of Italic tag < /i>
Note -you can write any text within <i> tag
Result - This is example of Italic tag
Html <em> Element Example
Example
<em> This is example of Italic tag < /em>
Note -The HTML <em> element defines emphasized text, with added semantic importance. <i> tag
Result - This is example of emphasized tag
Html <small> Element Example
Example
<small> This is example of small tag < /small>
Note -The HTML <small> element defines smaller text
Result - This is example of small element
Html <mark> Element Example
Example
<mark> This is example of mark tag < /mark>
Note -The HTML <mark> element defines marked or highlighted text
Result - This is example of mark element
Html <del> Element Example
Example
<del> This is example of del tag < /del>
Note -The HTML <del> element defines deleted (removed) text
Result -
This is example of del element
Html <ins>Element Example
Example
<ins> This is example of ins tag < /ins>
Note -The HTML <ins> element defines inserted (added) text.
Result -
This is example of ins element
Html <sub> Element Example
Example
<sub> This is example of sub tag < /sub>
Note -The HTML <sub> element represent subscripted text.
Result - This is example of sub element
Html <sup>Element Example
Example
<sup> This is example of sup tag < /sup>
Note -The HTML <sup> element represent superscripted text.
Result - This is example of superscripted text
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Wednesday, 20 September 2017

SQL Group By Clause

  Unknown       10:28       Select       No comments    

What is Group By clause ?

In this Article Group by clause use in Select query in Sql Server when you fetch data with collection on basis particular unique field then use Group by Clause. Group by clause with where condition and order by clause.
The GROUP BY statement is used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.
Syntex
SELECT ColumnName FROM TableName WHERE condition GROUP BY ColumnName ORDER BY ColumnName
Example
SELECT COUNT(Id) as Counts,City FROM Tbl_Employee GROUP BY City
Create table Tbl_Employee with some field and group by city.
if you run query with GROUP BY Clause then you find group wise city records.
In case if you use Group By Clause then always use aggregate functions.If you not use aggregate function then face error.
You can see in example


Select All records in image- image
Group by clause on city -


The HAVING Clause


The HAVING clause use in SQL because the WHERE keyword could not be used with aggregate functions.
Syntex

SELECT ColumnName, Aggregate Function(ColumnName) FROM TableName WHERE ColumnName operator value GROUP BY ColumnName HAVING Aggregate Function(ColumnName) operator value
SELECT COUNT(Salary) AS Counts,Salary,City FROM Tbl_Employee GROUP BY City ,Salary HAVING Salary > 25000
Note - You should aware having condition apply then this field must be in aggregate function and group by clause


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

Friday, 11 August 2017

IDENTITY_INSERT is set to OFF/ ON using SQL SERVER

  Unknown       11:10       Function       No comments    

In this Article introduce about IDENTITY_INSERT ON/OFF in SQL Server Discuss in detail with example see bleow discription in this Article

What is IDENTITY_INSERT


IDENTITY_INSERT When you create table in database then one field is ID then this field is integer type and autoincrement if yuow will set Identity(i,1), when you create table then insert any row then Identity column will autometic incremet by 1 this is the time IDENTITY_INSERT is OFF means you can't insert manualy. Means in insert query You can't insert id in table in example Follow some steps-
1st Steps - Create Data Base and Create Table in Sql Server like


CREATE TABLE Tbl_Identity
(
Id INT IDENTITY(1,1) PRIMARY KEY,
Name VARCHAR(100)
)
Note- This is syntax of Create table and execute run F5 in sql server

2nd Steps - After Create table You can insert data in table like in example

INSERT INTO Tbl_Identity (Id, Name) VALUES (1, 'Testing')
Note - Write Insert query and execute this query then you find a error

Error show like this-
Msg 544, Level 16, State 1, Line 6 Cannot insert explicit value for identity column in table 'Tbl_Identity' when IDENTITY_INSERT is set to OFF.

Create table and set Id int identity then id column is autometicaly incremented by 1 that the resion if you insert any row then id field is automatic incremented, in this previous example you insert any record in table then you find error when you execute and run this query because the IDENTITY_INSERT is OFF On Tbl_Identity That the resion you can't enter any new id manully...

So first of all You Set IDENTITY_INSERT ON
Syntex - Set IDENTITY_INSERT TableName ON
Example - Set IDENTITY_INSERT Tbl_Identity ON

Note - Write this syntex and execute

Set IDENTITY_INSERT ON Execute after that You can Insert query and pass id field manully using insert query and you find record is inserted successfully,Untill unless you can not insert id manully.
Note - If Table have ID field is autoincremented and You want to insert Id manually then First of all You should Set IDENTITY_INSERT [TableName] ON ,Run this query after you can insert and if you set Off then you can't insert id manually, Syntex - Set IDENTITY_INSERT [TableName] OFF , Run this query so identity Off

Set IDENTITY_INSERT ON/OFF using LINQ.


Insert identity on table you can change Id values in table through linq query Following some steps like -
  • 1st Step - Establish Connection (connect database in your project).
DummyShoppingEntities db = new DummyShoppingEntities();
Add entity in your project through add edmx file and automatic created connection string in web config file like this.
Ex. -Show in Web.Config file-
  <connectionStrings>
  <add name="DummyShoppingEntities" connectionString="metadata=res://*/Models.Dummy_DB.csdl|res://*/Models.Dummy_DB.ssdl|res://*/Models.Dummy_DB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-GFUF27H;initial catalog=Db_DummyShopping;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
Note-

name="DummyShoppingEntities" add name for access database in mvc

  • 2nd Step - Write query in linq.
Create Object of entity and write queryin sql in example-
public ActionResult Index()
{
 db.Database.ExecuteSqlCommand("Set IDENTITY_INSERT TableName ON;INSERT INTO    TableName (ColumnName, ColumnName) VALUES (ColumnValue, 'ColumnValue');Set  IDENTITY_INSERT Tbl_Identity TableName ");
db.SaveChanges();
 return View();
}
Example
public ActionResult Index()
{
db.Database.ExecuteSqlCommand("Set IDENTITY_INSERT Tbl_Identity ON;INSERT INTO Tbl_Identity (Id, Name) VALUES (2, 'Testing');Set IDENTITY_INSERT Tbl_Identity OFF ");
db.SaveChanges();
return View();
}

Note - In this example IDENTITY_INSERT on on table and write query in insert record in table and IDENTITY_INSERT off, Tbl_Identity is a table name
You can change another method also like
Example
public ActionResult Index()
{
Tbl_Identity item = new Tbl_Identity();
item.Id = 12;
item.Name = "";
db.Database.ExecuteSqlCommand("Set IDENTITY_INSERT Tbl_Identity ON;INSERT INTO Tbl_Identity (Id, Name) VALUES ("+ item.Id + ", '"+ item.Name+ "');Set IDENTITY_INSERT Tbl_Identity OFF ");
OR Add parameter also
db.Database.ExecuteSqlCommand("Set IDENTtestITY_INSERT Tbl_Identity ON;INSERT INTO Tbl_Identity (Id, Name) VALUES ({0},{1});Set IDENTITY_INSERT Tbl_Identity OFF,item.Id,item.Name ");
db.SaveChanges();
return View();
}

Note - Tbl_Identity is table name and you can define values in table field also

you can also use sql connection and add parameter like ado.net show in example like-

Example -
public ActionResult Index()
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["test"].ConnectionString);
SqlCommand sqlcom = new SqlCommand();
sqlcom.Connection = con;
if (con.State != System.Data.ConnectionState.Open)
{
con.Open();
}
ModelClass item = new ModelClass();
item.Id = 12;
item.Name = "test";
string query = "INSERT INTO Tbl_Identity (Id, Name) VALUES (@id,'" + item.Id + "', @name,'" + item.Name + "')";
sqlcom.Parameters.AddWithValue("id", item.Id);
sqlcom.Parameters.AddWithValue("id", item.Name);
db.Database.ExecuteSqlCommand("Set IDENTITY_INSERT Tbl_Identity ON;" + query + ";Set IDENTITY_INSERT Tbl_Identity OFF ");
db.SaveChanges();
con.Close();
return View();
}

Note - In this example firstly you establish a connection using sqlconnection and command after that open connection and declare model class and define properties.in this example class is "ModelClass" and set values then add parameter.Execute command identity insert on and insert record and identity off.

  • 3rd Steps - Work on Identity_Insert on and insert record theen off and save changes through linq. If u try this the you can easly insert id in table and update also.

Reset Identity Column in Sql Server

What is Reset Identity ?

Resest Identity - In Sql server whenever you create a table you define primary key identity means autometic increment by 1 when ever you insert record in table then so identity is autoincrement,Incase You want to change and reset identity field that is Reset Identity

Why Need to Reset Identity Column in sqlServer ?

In This artical we discuss about Reset identity column in table.Sometime you want to Change identity field in table like
Ex.
If you create a table and insert some record and you want to delete some record and again insert record then you find new inserted record those id number is different because Deleted record id number is skip. So you want to change identity field in table and maintain sequence then use Reset Identity.This more clear by Example see below example -
Example-

SELECT * FROM vibha1<Table Name> --Here Vibha1 is TableName

We get Values-











Delete data  from table
Ex. 

DELETE FROM vibha1 WHERE id=6
One Value Delete then Insert Value 

INSERT INTO vibha1(name) VALUES('vibha1')

Get Values-










Then We Use Code

Syntax: DBCC CHECKIDENT( <TableName>, RESEED, <ValuesThen Start>) 

And Delete id 7 record

DELETE FROM vibha1 WHERE id=7
Then  Execute This

 DBCC CHECKIDENT( vibha1 , RESEED, 5)
Then Insert

INSERT INTO vibha1(name) VALUES('vibha1')

Now Get Result

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

    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

    • 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...
    • 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...
    • 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...
    • Overview
        SQL (Structured Query Language)   SQL  is a language that interacts with the database on the server-side. This dynamite duo has changed ...
    • About Javascript
      What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting langua...
    • 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...
    • Operator in JavaScript
      What is an operator? JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binar...
    • Create First Application in MVC
      We want to create Firstly application in MVC first of how we create first application Show Steps   as below-     STEP 1 .  Start Computer ...
    • 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...

    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