You are on page 1of 13

Day1

HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>HTML Tutorial</title>
<meta charset="windows-1252">
<meta name="Keywords" content="HTML,CSS,XML,JavaScript,DOM,jQuery,ASP.NET " />
<meta name="Description" content="Free HTML CSS JavaScript" />
<link rel="stylesheet" type="text/css" href="/stdtheme.css">
<script type="text/javascript" src="filepath/filename.js"></script>

<script type="text/javascript">
function displayElement()
{
document.getElementById("err_url").value=addr;
document.getElementById("err_form").style.display="block";
document.getElementById("err_desc").focus();
hideSent();
}
</script>

</head>
<body>
<form id=frmLogin action=login.aspx method=post>
<h1>My First Heading</h1>

<p>My first paragraph.</p>


<input type=text value=This is some text>
<input type=button value=Save Data>
<input type=Submit value=Submit>
<input type=Reset value=Reset>

<table>
<tr><td>Test1</td><td>Test2</td></tr>
<tr><td>Test1</td><td>Test2</td></tr>
</table>

</form>
</body>
</html>

CSS

body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}

#para1
{
text-align:center;
color:red;
}

.center {text-align:center;}

External Style Sheets


<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>

Internal Style Sheets


<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>

InLine Styles
<p style="color:sienna;margin-left:20px">This is a paragraph.</p>

Order of Style, multiple styles present for same element


1.Inline style (inside an HTML element)
2.Internal style sheet (in the head section)
3.External style sheet
4.Browser default

body {background-color:#b0c4de;}
body {background-image:url('paper.gif');}
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
}

TextAlignment
p.main {text-align:justify;}

h3 {text-decoration:underline;} //Decoration
p.uppercase {text-transform:uppercase;} //Transformation

p{font-family:"Times New Roman", Times, serif;}


p.normal {font-style:normal;}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}

h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}

a:link {color:#FF0000;} /* unvisited link */


a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */

table, th, td
{
border: 1px solid black;
}

td
{
text-align:right;
}

table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}

XML
XML stands for eXtensible Markup Language.
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML was designed to transport and store data.
HTML was designed to display data.

XML stands for EXtensible Markup Language


XML is a markup language much like HTML
XML was designed to carry data, not to display data
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
XML is a W3C Recommendation

<?xml version="1.0" encoding="ISO-8859-1"?>


<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

<root>
<child>
<subchild>.....</subchild>
</child>
</root>

<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>

-Must have closing Tags


-case sensitive
-Properly nested
-Must have root element
-Attribute values must be quoted
-Special characters to be replaced, like &lt;, &gt;, &amp;, &apos;, &quot;
-whitespace is preserved
-

XML elements must follow these naming rules:


Names can contain letters, numbers, and other characters
Names cannot start with a number or punctuation character

Names cannot start with the letters xml (or XML, or Xml, etc)

Names cannot contain spaces

Javascript
Scripting Language. All HTML page use javascript to add functionality to pages

<!DOCTYPE html>
<html>
<head>
<script>
function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}
</script>
</head>
<body>

<h1>My First JavaScript</h1>


<p id="demo">This is a paragraph.</p>

<button type="button" onclick="displayDate()">Display Date</button>

</body>
</html>

document.write("<h1>This is a heading</h1>"); //Writing into HTML

<button type="button" onclick="alert('Welcome!')">Click Me!</button> //reacting to event

x=document.getElementById("demo") //Find the element


x.innerHTML="Hello JavaScript"; //Change the content

x=document.getElementById("demo") //Find the element


x.style.color="#ff0000"; //Change the style

if isNaN(x) {alert("Not Numeric")}; //Validate Input

ECMA-262 is the official name of the JavaScript standard.

Events onload, onclick, onmouseover, onblur

DataTypes are String, Number, Boolean, Array, Object, Null, Undefined, but all defined using
var keyword

Var s = This is a string;


Var x = 5;
Var y = true;
var cars=new Array();
cars[0]="Saab";
cars[1]="Volvo";
cars[2]="BMW";
OR
var cars=new Array("Saab","Volvo","BMW");
Array indexes are zero-based
var person={ //Object
firstname : "John",
lastname : "Doe",
id : 5566
};
name=person.lastname;
name=person["lastname"];
cars=null; //null values, when no value assigned it is undefined
person=null;

Function Syntax
function myFunction(name,job)
{
alert("Welcome " + name + ", the " + job);
}

function myFunction()
{
var x=5;
return x;
}

variable scope

String Functions
charAt() Returns the character at the specified index
concat() Joins two or more strings, and returns a copy of the joined strings
fromCharCode() Converts Unicode values to characters
indexOf() Returns the position of the first found occurrence of a specified value in a string
lastIndexOf() Returns the position of the last found occurrence of a specified value in a string
replace() Searches for a match between a substring (or regular expression) and a string, and
replaces the matched substring with a new substring
split() Splits a string into an array of substrings
substr() Extracts the characters from a string, beginning at a specified start position, and
through the specified number of character
substring() Extracts the characters from a string, between two specified indices
toLowerCase() Converts a string to lowercase letters
toUpperCase() Converts a string to uppercase letters

isNaN()
parseInt()
eval()

var d = new Date();


var n = d.getDate();

getDate() Returns the day of the month (from 1-31)


getDay() Returns the day of the week (from 0-6)
getFullYear() Returns the year (four digits)
getHours() Returns the hour (from 0-23)
getMilliseconds() Returns the milliseconds (from 0-999)
getMinutes() Returns the minutes (from 0-59)
getMonth() Returns the month (from 0-11)
getSeconds() Returns the seconds (from 0-59)
getTime() Returns the number of milliseconds since midnight Jan 1, 1970
getYear() Deprecated. Use the getFullYear() method instead
toDateString() Converts the date portion of a Date object into a readable string
toLocaleDateString() Returns the date portion of a Date object as a string, using locale
conventions
toLocaleTimeString() Returns the time portion of a Date object as a string, using locale
conventions
toLocaleString() Converts a Date object to a string, using locale conventions
toString() Converts a Date object to a string
UTC() Returns the number of milliseconds in a date string since midnight of January 1, 1970,
according to universal time

Popups alert, confirm, prompt


var r=confirm("Press a button");
if (r==true)
{
x="You pressed OK!";
}
else
{
x="You pressed Cancel!";
}

var person=prompt("Please enter your name","ABC");


if (person!=null && person!="")
{
x="Hello " + person + "! How are you today?";
}

Control statements
if( myVariable == 2 ) { //If
myVariable = 1;
} else {
myVariable = 0;
}

for( var myVariable = 1; myVariable <= 5; myVariable++ ) { //for


myArray[myVariable] = 1;
}

while( myVariable <= 5 ) { //while


myArray[myVariable] = 1;
myVariable++;
}

do { //do-while
myArray[myVariable] = 1;
myVariable++;
} while

switch(myVar) { //switch
case 1:
//if myVar is 1 this is executed
case 'sample':
//if myVar is 'sample' (or 1, see the next paragraph)
//this is executed
case false:
//if myVar is false (or 1 or 'sample', see the next paragraph)
//this is executed
default:
//if myVar does not satisfy any case, (or if it is
//1 or 'sample' or false, see the next paragraph)
//this is executed
}

var myVariable = document.getElementById ? 1 : 0; //short-if

try {
//do something that might cause an error
} catch( myError ) {
//if an error occurs, this code will be run
//two properties will (by default) be available on the
//object passed to the statement
alert( myError.name + ': ' + myError.message );
} finally {
//optional - this code will always be run before the
//control structure ends, even if you rethrow the error
//in the catch
}

Continue & break

JS Validations
function validate()
{

if( document.myForm.Name.value == "" )


{
alert( "Please provide your name!" );
document.myForm.Name.focus() ;
return false;
}
if( document.myForm.Country.value == "-1" )
{
alert( "Please provide your country!" );
return false;
}
return( true );
}

DHTML
Interactive website
Toggle display of Div or elements based on events like onclick, hover, onmouseup,
onmousedown, onmouseover, onmouseout, etc

WebProgramming

Web Concept

Client/Server
The clientserver model is a distributed application structure in computing that partitions tasks
or workloads between the providers of a resource or service, called servers, and service
requesters, called clients.[1] Often clients and servers communicate over a computer network
on separate hardware, but both client and server may reside in the same system. A server is a
host that is running one or more server programs which share their resources with clients. A
client does not share any of its resources, but requests a server's content or service function.
Clients therefore initiate communication sessions with servers which await incoming requests.

IIS
Application Pool, Virtual Directory, Self SSL, Error Pages, ASP.NET CGI restrictions,
Authentication, iisreset, logs.

.NET Framework versions


CLR

The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET
framework and is responsible for managing the execution of .NET programs. In a process
known as Just-in-time compilation, the compiled code is converted into machine instructions
that, in turn, are executed by the computer's CPU. The CLR provides additional services
including memory management, type safety and exception handling. All programs written for
the .NET framework, regardless of programming language, are executed by the CLR. It
provides exception handling, garbage collection and thread management. CLR is common to
all versions of the .NET framework.

The CLR is Microsoft's implementation of the Common Language Infrastructure (CLI) standard.

.NET Class Library


System The System namespace contains fundamental classes and base classes that define
commonly-used value and reference data types, events and event handlers, interfaces,
attributes, and processing exceptions.
System.Collections The System.Collections namespaces contain types that define various
standard, specialized, and generic collection objects.
System.Data The System.Data namespaces contain classes for accessing and managing data
from diverse sources. The top-level namespace and a number of the child namespaces
together form the ADO.NET architecture and ADO.NET data providers. For example, providers
are available for SQL Server, Oracle, ODBC, and OleDB. Other child namespaces contain
classes used by the ADO.NET Entity Data Model (EDM) and by WCF Data Services.
System.Diagnostics The System.Diagnostics namespaces contain types that enable you to
interact with system processes, event logs, and performance counters. Child namespaces
contain types to interact with code analysis tools, to support contracts, to extend design-time
support for application monitoring and instrumentation, to log event data using the Event
Tracing for Windows (ETW) tracing subsystem, to read to and write from event logs and collect
performance data, and to read and write debug symbol information.
System.DirectoryServices The System.DirectoryServices namespaces contain types that
provide access to Active Directory from managed code.
System.Drawing The System.Drawing parent namespace contains types that support basic
GDI+ graphics functionality. Child namespaces support advanced two-dimensional and vector
graphics functionality, advanced imaging functionality, and print-related and typographical
services. A child namespace also contains types that extend design-time user-interface logic
and drawing.
System.Globalization The System.Globalization namespace contains classes that define
culture-related information, including language, country/region, calendars in use, format
patterns for dates, currency, and numbers, and sort order for strings. These classes are useful
for writing globalized (internationalized) applications. Classes such as StringInfo and TextInfo
provide advanced globalization functionalities, including surrogate support and text element
processing.
System.IO The System.IO namespaces contain types that support input and output, including
the ability to read and write data to streams either synchronously or asynchronously, to
compress data in streams, to create and use isolated stores, to map files to an application's
logical address space, to store multiple data objects in a single container, to communicate
using anonymous or named pipes, to implement custom logging, and to handle the flow of
data to and from serial ports.
System.Linq The System.Linq namespaces contain types that support queries that use
Language-Integrated Query (LINQ). This includes types that represent queries as objects in
expression trees.
System.Reflection The System.Reflection namespaces contain types that provide a managed
view of loaded types, methods, and fields, and that can dynamically create and invoke types.
A child namespace contains types that enable a compiler or other tool to emit metadata and
Microsoft intermediate language (MSIL).
System.Text The System.Text namespaces contain types for character encoding and string
manipulation. A child namespace enables you to process text using regular expressions.
System.Threading The System.Threading namespaces contain types that enable
multithreaded programming. A child namespace provides types that simplify the work of
writing concurrent and asynchronous code.
System.Web The System.Web namespaces contain types that enable browser/server
communication. Child namespaces include types that support ASP.NET forms authentication,
application services, data caching on the server, ASP.NET application configuration, dynamic
data, HTTP handlers, JSON serialization, incorporating AJAX functionality into ASP.NET,
ASP.NET security, and web services.
System.Windows The System.Windows namespaces contain types used in Windows
Presentation Foundation (WPF) applications, including animation clients, user interface
controls, data binding, and type conversion. System.Windows.Forms and its child namespaces
are used for developing Windows Forms applications.
System.Workflow The System.Workflow namespaces contain types used to develop
applications that use Windows Workflow Foundation. These types provide design time and run-
time support for rules and activities, to configure, control, host, and debug the workflow
runtime engine.
System.Xaml The System.Xaml namespaces contain types that support parsing and
processing the Extensible Application Markup Language (XAML).
System.Xml The System.Xml namespaces contain types for processing XML. Child
namespaces support serialization of XML documents or streams, XSD schemas, XQuery 1.0
and XPath 2.0, and LINQ to XML, which is an in-memory XML programming interface that
enables easy modification of XML documents.
Microsoft.CSharp The Microsoft.CSharp namespaces contain types that support compilation
and code generation of source code written in the C# language, and types that support
interoperation betwen the dynamic language runtime (DLR) and C#.
Microsoft.SqlServer.Server The Microsoft.SqlServer.Server namespace contains classes,
interfaces, and enumerations that are specific to the integration of the Microsoft .NET
Framework common language runtime (CLR) into Microsoft SQL Server, and the SQL Server
database engine process execution environment.
Microsoft.VisualBasic The Microsoft.VisualBasic namespaces contain classes that support
compilation and code generation using the Visual Basic language. Child namespaces contain
types that provide services to the Visual Basic compiler and types that include support for the
Visual Basic application model, the My namespace, lambda expressions, and code conversion.

Websites webservices

Intrinsic Objects in asp.net Request, Response, Server, Application, Session

Request to read input from Client


fname=Request.Cookies["firstname"]
Request.Form["firstname"]
Request.QueryString[Page_Mode]
Request.ServerVariables[REMOTE_ADDR], ALL_HTTP, CONTENT_LENGTH, HTTP_REFERER,
HTTP_USER_AGENT, HTTPS, LOCAL_ADDR, REMOTE_HOST, SERVER_NAME, URL
Request.BinaryRead
Request.TotalBytes

Response to send response to Client


Response.Cookies[cookieName]["LocationId"] = cookieToWrite;
Response.Cookies[cookieName].Expires = DateTime.Now.AddDays(1000);

Response.Buffer=true/false
Response.Flush
Response.Expires = -1 //page never cached, mins specified
Response.Write
Response.Redirect
Response.Clear
Response.End
Response.BinaryWrite

Server.scripttimeout in seconds
Server.CreateObject
Server.Execute
Server.HTMLEncode
Server.MapPath
Server.Transfer
Server.URLEncode

Application.Lock
Application.Unlock
Application[Object_Name]
Application onstart, onend

Session.SessionID
Session.Timeout in mins
Session.Abandon
Session[Session_Object_Name]
Session onStart, onEnd
Response.Redirect: tells the browser that the requested page can be found at a new location.
The browser then initiates another request to the new page loading its contents in the
browser. This results in two requests by the browser.

Server.Transfer: It transfers execution from the first page to the second page on the server. As
far as the browser client is concerned, it made one request and the initial page is the one
responding with content. The benefit of this approach is one less round trip to the server from
the client browser. Also, any posted form variables and query string parameters are available
to the second page as well.

Web.config/machine.config
<configuration>

<configSections>
<sectionGroup>
</sectionGroup>
</configSections>

<system.web>
</system.web>

<connectionStrings>
</connectionStrings>

<appSettings>
</appSettings>
</configuration>

<?xml version="1.0"?>
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
<compilation debug="true" strict="false" explicit="true" />
<pages enableViewStateMac="true" enableEventValidation="true"
viewStateEncryptionMode="Always">
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />

</namespaces>
<controls>
<add src ="~/controls/ctl.ascx" tagPrefix ="mycontrol" tagName ="ctl1"/>
</controls>
</pages>
</system.web>
</configuration>

Authentication models Integrated windows, Forms Based, Passport


Anonymous Access
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization>

Anynymous-Windows->Digest->Basic

Authorization Access verification on resources

Page PreInit, Init, PreLoad, Load, ControlEvents, LoadComplete, PostBackEvent, Render,


Unload

www.w3schools.com
http://www.codeproject.com/Articles/98950/ASP-NET-authentication-and-authorization

You might also like