Documente Academic
Documente Profesional
Documente Cultură
NET
Peter Gfader
Senior Software Architect
Peter Gfader
Homework?
An ASP.NET
Master Pages
Themes & skins
LAB
http://sharepoint.ssw.com.au/Training/UTSNET/
Overview of .NET Data in Forms Usability - Rules to Better Windows Forms Deployment and Security of Windows Forms Web Services and Threading
http://sharepoint.ssw.com.au/Training/UTSNET/
4. 5.
Overview of .NET Webforms TODAY Data in Webforms Usability Rich Web Forms and Other ASP.NET Features Web Security Advanced Topics & Future Technology (Silverlight)
The web
HTML
HyperText Markup Language Describes a web page <html> <head> <title>Hello HTML</title> </head> <body> <p>Hello World!</p> </body> </html>
http://en.wikipedia.org/wiki/HTML
HTTP
HTTP/1.1 200 OK Date: Mon, 23 May 2005 22:38:34 GMT Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT Content-Length: 438 Content-Type: text/html; charset=UTF-8
http://en.wikipedia.org/wiki/Http
Request / Response
Request www.ssw.com.au The Internet Response Client HTML Server
Files
.NET Overview
CLR
= Virtual machine
What Is ASP.NET?
ASP.NET provides a complete environment for building, deploying, and running .NET Web applications.
Developer Productivity
Simplified page development model Target any Web client (PC or mobile device) Modular, well-factored, extensible architecture Superior debugging and tracing support Compiled, not interpreted Rich caching support Web farm scalable session state Automatically detects and recovers from errors No need to bring down Web server Deploy and upgrade running applications with XCOPY XML configuration files
User requests an application resource from the Web server. IIS forwards the call to ASP.NETs process Application manager calls the Application domain & Processes the page.
.NET Framework
ASP.NET Compilation
Parse
ASPX Engine
Generate
Request Request
ASPX File
Instantiate
Response (HTML/js/dhtml/etc)
Page Class
Dont use this, here for compatibility only File > New > Web Site Each page is dynamically loaded into memory Slow on first load after deployment No need to recompile for code change
Recommended File > New > Projects, then Select Web Application Compiles all pages into one DLL Faster on first load after deployment Must recompile whole site for code change Not available in Default VS 2005, requires SP2
ASP.NET
Compilation
Request Request
ASPX File
Instantiate
Response (HTML/js/dhtml/etc)
Page Class
ASP.NET
Compilation
Parse
ASPX Engine
Generate
Web Application Request Request ASPX File Instantiate Gend Page Class File
Page Class
The Page
Visual elements, which include markup, server controls, and static text. Programming logic for the page, which includes event handlers and other code.
2.
The Single-File Page Model <%@ Page Language="VB> <script runat=server> </script> The Code-Behind Page Model <%@ Page Language="VB CodeFile="SamplePage.aspx.vb Inherits="SamplePage AutoEventWire="false" %>
A Page's Life
Page request Start Page Initialization Load Validation Postback Event handling Rendering Unload
http://msdn.microsoft.com/en-us/library/ms178472.aspx
Occurs before the page life cycle begins. When the page is requested by a user
ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or if a cached version of the page can be sent in response without running the page.
Request and
Response
Determines whether the request is a postback or a new request and sets the IsPostBack property. Sets the page's UICulture property
If the current request is a postback, control properties are loaded with information recovered from view state and control state.
The Validate method of all validator controls is called Sets the IsValid property of
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
At this point, page properties such as Response and Request are unloaded and any cleanup is performed.
Page request Start Page Initialization Load Validation Postback Event handling Rendering Unload
http://msdn.microsoft.com/en-us/library/ms178472.aspx
ASP.NET Postbacks
A Page Postback is:
Where the client communicates back to the server, Through the page that was originally served. The post back is a submission of the Form element.
ASP.NET Viewstate
Page ViewState
Allows the state of objects (serializable) to be stored in a hidden field on the page.
Server states
ASP.NET States
Session State allows the state of objects (serializable) to be stored for a single session (lifetime of the users browser or specific timeout)
Application State allows the state of objects (serializable) to be stored for the application across different sessions.
Server controls
Example:
<asp:Button id="button1" Text="Click me!"
runat="server"
OnClick="submit" />
Demo
How to create a web application How to create a web form Designer Features Different Page Code models Postbacks Viewstate, Session State, Application State
User controls
A group of server controls that are created by the user. Encapsulates certain functionality
E.g
ASP.NET Configuration
ASP.NET Configuration
Web.Config
Similar to app.config in windows Application-wide configuration Provide application settings In XML, so its easy to change
Master pages new concept in ASP.NET 2.0 Allows site developers to build master templates for their site's look and feel Put common code shared by all the pages on the master page A page that references a Master Page is called a Content Page.
At the page level (in the page) <%@ Page Language="C# MasterPageFile="MySite.Master" %>
Validation
ASP.NET: Validation
A Validation server control is used to validate the data of an input control. If the data does not pass validation, it will display an error message to the user.
ASP.NET: Validation
Important Properties:
Dynamic space the control uses isnt reserved for the control Static space control uses is always reserved None control is invisible
BackColor="lightblue"
ForeColor="black" />
> Controls.skin
> PinkTheme.css
Applying Themes
Apply a theme to a Web site <configuration> <system.web> <pages theme="ThemeName" /> </system.web> </configuration>
Done
Resources
Firebug
http://getfirebug.com/
ASP.NET Webforms
http://www.asp.net/web-forms/
ASP.NET MVC
http://www.asp.net/mvc/
Resources
ASP.NET AJAX
http://www.asp.net/ajax/
http://msdn.microsoft.com/rampup
Resources ASP.NET
Quickstarts
http://quickstarts.asp.net/
Master pages
http://www.asp.net/learn/master-pages/
http://www.asp.net/learn/moving-to-asp.net-2.0/module-10.aspx
Page lifecycle
http://www.asp.net/learn/videos/video-6558.aspx
Resources ASP.NET
Validation
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/defa ult.aspx
http://www.asp.net/learn/videos/video-05.aspx
User controls
http://www.asp.net/learn/videos/video-194.aspx
Resources - Usergroups
http://www.sddn.org.au/
http://www.sdnug.org/
http://www.ncg.asn.au/
http://www.ssw.com.au/ssw/NETUG/Sydney.aspx
3 things
Thank You!
Gateway Court Suite 10 81 - 91 Military Road Neutral Bay, Sydney NSW 2089 AUSTRALIA ABN: 21 069 371 900