《aspnet培训》由会员分享,可在线阅读,更多相关《aspnet培训(93页珍藏版)》请在金锄头文库上搜索。
1、ASP.NET Development,Agenda,What is ASP.NET? Web Forms Server Controls & User Controls Databinding ASP.NET Pages ASP.NET Caching ASP.NET Configuration ASP.NET Security ASP.NET Applications Deploying ASP.NET Web Applications,What is ASP.NET?,Microsofts platform for building Web Applications Part of th
2、e .NET Framework Server Side Technology,.NET Framework,Base Class Library,Common Language Specification,Common Language Runtime,ADO.NET: Data and XML,VB,C+,C#,Visual Studio.NET,ASP.NET: Web Services and Web Forms,JScript,Windows Forms,ASP.NET,Base Class Library,Common Language Specification,Common L
3、anguage Runtime,VB,C+,C#,Visual Studio.NET,ASP.NET: Web Services and Web Forms,JScript,Windows Forms,ADO.NET: Data and XML,ASP.NET Features,ASPX, ASP Side by Side Simplified Programming Model Control-based, event-driven execution model Code Behind Pages Powerful Controls Powerful Data Access Better
4、Performance Executed via CLR as native code,ASP.NET Feature,Simplified Browser Support Simplified Form Validation Better Session Management Caching Security Web Services Simplified Deployment,ASP.NET Execution Model,ASPX,.ASPX,ASP.NET Execution Model,.ASPX,Compiled,ASP.NET Execution Model,.ASPX,Comp
5、iled,ASP.NET Execution Model,.ASPX,Compiled,.ASPX,Compiled,ASP.NET Execution Model,demo,Agenda,What is ASP.NET? Web Forms Server Controls & User Controls Databinding ASP.NET Pages ASP.NET Caching ASP.NET Configuration ASP.NET Security ASP.NET Applications Deploying ASP.NET Web Applications,Web Form
6、Pages Part Declarative, Part Code,Declarative “tags” HTML, server controls, static text Server Side Code Great separation between code and markup,Form1.aspx,code,Form1.aspx,code,Form1.vb,single file,separate files (“code-behind”),A Page Can Include,Runtime Compilation,ASP.NET Page Life Cycle,Similar
7、 to Microsoft Win32 application Events raised as page created Form_Initialize() - Page_Init() Form_Load() - Page_Load() Form_Activate() - Page_PreRender() Form_Unload() - Page_Unload(),Simple ASP.NET Page,demo,Agenda,What is ASP.NET? Web Forms Server Controls & User Controls Databinding ASP.NET Page
8、s ASP.NET Caching ASP.NET Configuration ASP.NET Security ASP.NET Applications Deploying ASP.NET Web Applications,ASP.NET Server Controls,Server controls encapsulate Rendering Behavior Generate markup that is sent to the client DHTML, HTML 3.2, WML, etc. Offer up dynamic experience Process input sent
9、 from client Bind to data Fire server side events for notifications,Standard ASP.NET Controls,Web Controls Render client-targeted HTML and script Consistent, strongly-typed object model Some render as single HTML tags: Button, TextBox, DropDownList Some render richer HTML + script: DataGrid, Calenda
10、r, Validators Html Controls Map 1:1 with HTML tags,ASP.NET Server Controls, Runat Enables Server Side Processing,Required validator control Range validator control Compare validator control Regular expression validator Custom validator control,ASP.NET Validation Control,ASP.NET Server Control,demo,C
11、ontrol Event Processing,Events are: Triggered on the client Handled in server code Requires a postback to the same page Relies on State Management,Handling Control Events,Wire up the handler on the tag: Event handler code: Sub btn1_Click(s as Object,e as EventArgs) Message.Text = “Button1 clicked“ E
12、nd Sub VS.NET,Page/Control Event Execution,Page_Load,Page_Unload,Textbox1_Changed,Button1_Click,(on PostBack),1. Change Events,2. Action Events,Page is loaded, control hierarchy initialized,Page is disposed,Control hierarchy is rendered,Page_Load Details,Page_Load fires on every request Test Page.Is
13、PostBack to execute conditional logic Example: Sub Page_Load(s As Object,e As EventArgs) If Not Page.IsPostBack Then executes only on initial page load Message.Text = “initial value“ End If End Sub,State Management,ViewState helps restore control to its previous state Implemented as a hidden form fi
14、eld Disable via: EnableViewState=false SessionState used to store data associated with the current session,Postback Forms,demo,User Controls,Server controls, authored like pages Enable full encapsulation Supports nested controls Separate code namespace Separate code language Great way to partition w
15、ork Great way to reuse work across multiple pages and applications, Directive,Registers User Control for use on a Web Forms page: ,Exposing An Object Model,User controls expose an object model Properties, Fields, Events, Methods Example: public string Color get set ,Creating a User Control,demo,Agen
16、da,What is ASP.NET? Web Forms Server Controls & User Controls Databinding ASP.NET Pages ASP.NET Caching ASP.NET Configuration ASP.NET Security ASP.NET Applications Deploying ASP.NET Web Applications,Web Forms Data Binding,Provides a simple, declarative way to bind Web UI elements to data “Simple” binding to a single property “List” binding to a data source DataGrid, DropDownList, etc. Huge variety of data sources su