Home > Documents > Introduction to ASP.NET. Chapter Objectives Static and Dynamic Web Applications Static Web pages...

Introduction to ASP.NET. Chapter Objectives Static and Dynamic Web Applications Static Web pages...

Date post: 21-Dec-2015
View: 215 times
Download: 1 times
Share this document with a friend
Embed Size (px)
of 47 /47
Introduction to ASP.NET
  • Slide 1
  • Introduction to ASP.NET
  • Slide 2
  • Chapter Objectives
  • Slide 3
  • Static and Dynamic Web Applications Static Web pages Created with HTML controls Dynamic Web pages Allow user to interact with the Web page Changes appearance or content Created with Microsofts Active Server Pages.NET (ASP.NET) Used to build server-side Web applications
  • Slide 4
  • Processing a Request for a Web Page
  • Slide 5
  • ASP.NET Main ASP.NET applications 1.Web Forms Used to process forms and develop cross- browser applications Uses.aspx file extension 2.Web Services Other applications can interact with your program Uses.asmx file extension
  • Slide 6
  • Web Forms ASP.NET pages within an ASP.NET application Identified with file extension.aspx 2 logical areas: HTML template Contains design layout, content, and controls Collection of code commonly located behind Web Form
  • Slide 7
  • HTML Server Controls Similar to HTML controls except processed by server Write runat=server to transform HTML control into HTML Server control Controls have closing tag, or end with /> HTML control: HTML Server control: Yes
  • Slide 8
  • ASP.NET Server Controls Creates HTML code ASP.NET controls usually identified with prefix asp: followed by name of the control Types of ASP.NET Server Controls ASP.NET Form Controls (Web controls) Data Validation Controls User Controls Mobile Controls
  • Slide 9
  • HTML Server Versus ASP.NET Server Controls ASP.NET form controls also have different properties than their HTML server control counterparts HTML Server label control Message1.InnerHTML = "Product 1" ASP server label control Message2.Text = "Product 2"
  • Slide 10
  • Browser Source Code Look at the browsers source code for each ASP.NET page to understand what the Web server is sending to the browser ASP.NET code is never sent to the browser Only HTML tags, along with client-side scripts, are sent to the browser Many errors are related to the syntax of the HTML that is sent to the browser, such as a missing closing tag, or a missing quotation mark You can quickly locate HTML syntax errors
  • Slide 11
  • Server Controls within Visual Studio.NET
  • Slide 12
  • Code Behind the Page Written in an ASP.NET-compatible language File extension is.vb if code is written in Visual Basic.NET Compiled code behind the page is the class definition for the page When you build the application, you compile the code into an executable file stored in the bin directory
  • Slide 13
  • The Code Behind the Page
  • Slide 14
  • Postback Posting back data into form The _ViewState hidden form field Very long encoded string Contains information required to maintain form data across multiple page requests Value changes each time form is reposted EnableViewState property Turns postback feature on or off. To turn off:
  • Slide 15
  • Postback data using the _ViewState hidden field
  • Slide 16
  • Page Class Events The first time a page is requested by a client, a series of page events occurs Page_Init initializes page control hierarchy Page_Load loads any server controls into memory and occurs every time page is executed Server control events action and change events occur when page is posted back to the server Page_PreRender occurs immediately before control hierarchy is rendered and sent to the browser Page_Unload removes page from servers memory
  • Slide 17
  • Page Class Event Cycle
  • Slide 18
  • Page_Load Event Procedure Begin procedure with keyword Sub End procedure with keywords End Sub Sub Page_Load(s As Object, e As EventArgs) Message.InnerHtml = Welcome! End Sub
  • Slide 19
  • Server Control Events When user clicks the button, an OnServerClick event handler is called Client side onClick triggers event that returns a server click event