Presentation Transcript
Chapter 3 - Exploring ASP.NET and Web Forms : Chapter 3 - Exploring ASP.NET and Web Forms
Web Forms : Web Forms Rendering
Programming
.NET Framework
Extensibility
WYSIWYG
Code Separation
State Management
Two Programming Models : Two Programming Models Single file programming model
Good for ASP migration
Code-behind (double-file) programming model
Provides client/server code separation
Hello World Sample Source : Hello World Sample Source <%@ Page Language="vb" %>
Hello World Web Page
Hello World Browser Source : Hello World Browser Source
Hello World Web Page
Server Tag Changes : Server Tag Changes
Server Controls : Server Controls HTML Server Controls
Used when:
Migrating existing ASP pages to ASP.NET
The Web page requires a great amount of client-side code, where client-side events need to be programmed extensively
Web Server Controls
More consistent interface
Preferred
__VIEWSTATE (ViewState) : __VIEWSTATE (ViewState) Stores data across calls to the server
Holds
Primitive types
Strings
HashTables
ArrayLists
Post Back : First Request for myPage User fills in form and submits data Http “Get” myPage.aspx ( no data ) Response = myPage.aspx Browser Http “Post” myPage.aspx ( data ) IsPostBack = false IsPostBack = true Web Server Response = myPage.aspx Post Back
Responding to Events : Responding to Events
Hello World Web Page
Slide11 : optional
code-behind
Base.vb myPage.aspx Request from Browser execute
.dll * generate
.vb class file * Aspx Engine
parse
myPage.aspx Language Compiler
create
.dll file * Yes No Response to Browser optional
compiled
code-behind
pages
myProject.dll * Files created within the following folder structure:
%SystemRoot%\Microsoft.NET\Framework\version\Temporary ASP.NET Files\ .aspx file
changed? No Yes compiled?
Slide12 : Code-Behind Page: myPage.aspx.vb
…
Public Class myPage
…
Protected WithEvents btnSelect As System.Web.UI.WebControls.Button
Protected WithEvents txtName as System.Web.UI.WebControls.TextBox
… Web Form Page: myPage.aspx
<% Page language="vb" Codebehind="myPage.aspx.vb" Inherits="ch3.myPage" %>
…
…
Slide13 : Class Selection Event Method Selection
Page Layout : Page Layout Grid Layout
Drag and drop controls anywhere
Great for fixed size page
Flow Layout
Similar to traditional ASP
Requires tables / nested tables for layout
Can also have advantages
Lab – Creating a Web Form : Lab – Creating a Web Form
Catch the
buzz on authorSTREAM
Copyright © 2002-2008 authorSTREAM. All rights reserved.