+ All Categories
Home > Documents > Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code...

Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code...

Date post: 13-Jan-2016
Category:
Upload: christian-cooper
View: 229 times
Download: 1 times
Share this document with a friend
24
Module 1: Working with ASP.NET
Transcript
Page 1: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Module 1: Working with ASP.NET

Page 2: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Overview

Introducing ASP.NET

Creating Web Forms

Adding ASP.NET Code to a Page

Handling Page Events

Discussion: ASP vs. ASP.NET

Page 3: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Introducing ASP.NET

The .NET Framework

ASP.NET Features

Animation: The ASP.NET Execution Model

Page 4: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

The .NET Framework

.NET.NETFramework Framework

.NET.NETFramework Framework

InternetInternetInternetInternet

COM+COM+COM+COM+

OrchestrationOrchestration OrchestrationOrchestration

Windows Windows

.NET Enterprise

Servers

.NET Enterprise

Servers

BuildingBuildingBlockBlock

ServicesServices

BuildingBuildingBlockBlock

ServicesServices

Visual Studio.NET Visual Studio.NET

Base Class LibraryBase Class Library

ADO.NET: Data & XMLADO.NET: Data & XML

UserUserInterfaceInterface

Common Language RuntimeCommon Language Runtime

WebWebServicesServices

Page 5: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

ASP.NET Features

Multiple Language Support

Increased Performance

Compiled code

Cache

Classes and Namespaces

Server Controls

Web Services

Page 6: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

ASP.NET Features (continued)

Improved Security

Greater Scalability

Cookie-less Sessions

Easy Configuration and Deployment

Page 7: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Animation: The ASP.NET Execution Model

Page 8: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Creating Web Forms

What Are Web Forms?

What Are Server Controls?

Types of Server Controls

How Do Server Controls Work?

Demonstration: Adding Server Controls to an ASP.NET Page

Page 9: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

What Are Web Forms?

.aspx extension

@Page Directive

Framework Is an Object Model

Denoted by the runat="server" Attribute

Contain Client-side and Server-side Code

Contain HTML and Server Controls

<Form runat="server"></Form>

<Form runat="server"></Form>

<%@ Page Language=“C#" %> <%@ Page Language=“C#" %>

Page 10: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

What Are Server Controls?

Server-programmable Objects

Denoted by Tag with the runat = "server" Attribute

Encapsulate Both Behavior and Rendering

Fully Declarative

Render Different HTML to Support Multiple Browsers or other Web Clients

Page 11: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Types of Server Controls

HTML Controls

Exist within the System.Web.UI.HtmlControls namespace

Web Controls

Exist within the System.Web.UI.WebControls namespace

<input type="text" id="txtName" runat="server"><span id="spnStarter" runat="server">starter</span>

<input type="text" id="txtName" runat="server"><span id="spnStarter" runat="server">starter</span>

<asp:TextBox id="txtName" runat="server"Text="[Entry Keywords]"/>

<asp:TextBox id="txtName" runat="server"Text="[Entry Keywords]"/>

Page 12: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

How Do Server Controls Work?

Declared with runat="server" Attribute

When the ASP.NET Page is Executed:

Creates action and method attributes of form

Adds unique id and name attributes to controls

Adds value attribute to controls

Adds a hidden control to the form to save view state information

<input type="text" id="text2" runat="server"><input type="text" id="text2" runat="server">

Page 13: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Demonstration: Adding Server Controls to an ASP.NET Page

Page 14: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Adding ASP.NET Code to a Page

Creating ASP.NET <SCRIPT> Section

Creating Event Procedures

Demonstration: Adding Code to Controls

Page 15: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Creating ASP.NET <SCRIPT> Section

Declaring the Language

Declaring Functions and Subroutines

<script language="VB" runat="server"><script language="C#" runat="server">

<script language="VB" runat="server"><script language="C#" runat="server">

<SCRIPT LANGUAGE="VB" runat="server"> Sub login () 'contents of routine End Sub</SCRIPT>

<SCRIPT LANGUAGE="VB" runat="server"> Sub login () 'contents of routine End Sub</SCRIPT>

Page 16: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Creating Event Procedures

Assign a Method Name to the Event Attribute

Create an Event Procedure in Your Page Code

Access Properties of Controls in the Event Procedure

<input type="submit" value="Submit!" onServerClick="GreetMe" runat="server">

<input type="submit" value="Submit!" onServerClick="GreetMe" runat="server">

Sub GreetMe(s As Object, e As EventArgs) Sub GreetMe(s As Object, e As EventArgs)

Sub GreetMe(s As Object, e As EventArgs) spnGreeting.InnerHTML = "Hello " & _

txtName.ValueEnd Sub

Sub GreetMe(s As Object, e As EventArgs) spnGreeting.InnerHTML = "Hello " & _

txtName.ValueEnd Sub

Page 17: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Demonstration: Adding Code to Controls

Page 18: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Handling Page Events

Page Event Life Cycle

Handling Postback Forms

Demonstration: Using Postback Forms

Page 19: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Page Event Life Cycle

Page_LoadPage_Load

Page_UnloadPage_Unload

Textbox1_ChangedTextbox1_Changed

Button1_ClickButton1_Click

Page is disposed

Page_InitPage_Init

Page 20: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Handling Postback Forms

ViewState Control Maintains the State of a Page During Postback

Page_Load Fires on Every Request

Use Page.IsPostBack to execute conditional logic

Sub Page_Load(s As Object, e As EventArgs) If Not Page.IsPostBack Then 'executes only on initial page load End If 'Rest of procedure executes on every requestEnd Sub

Sub Page_Load(s As Object, e As EventArgs) If Not Page.IsPostBack Then 'executes only on initial page load End If 'Rest of procedure executes on every requestEnd Sub

Page 21: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Demonstration: Using Postback Forms

Page 22: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Discussion: ASP vs. ASP.NET

Page 23: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Lab 1: Using ASP.NET to Output Text

Page 24: Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.

Review

Introducing ASP.NET

Creating Web Forms

Adding ASP.NET Code to a Page

Handling Page Events

Discussion: ASP vs. ASP.NET


Recommended