Presentation is loading. Please wait.

Presentation is loading. Please wait.

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Web Applications.

Similar presentations


Presentation on theme: "McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Web Applications."— Presentation transcript:

1

2 McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Web Applications

3 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-2 Chapter Objectives - 1 Explain the functions of the server and the client in Web programming Create a Web Form and run it in a browser Describe the differences among the various types of Web controls and the relationship of Web controls to controls used on Windows forms Understand the event structure required for Web programs Design a Web Form using tables

4 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-3 Chapter Objectives - 2 Control the styles used on Web pages using cascading style sheets (CSS) Create multiple pages in a Web application Navigate using the HyperLink control and the Server object Validate Web input using the validator controls Use state management to preserve values in variables Use AJAX to update a portion of a Web page Define ASP.NET, XML, WSDL, and SOAP

5 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-4 4 What Are Active Server Pages? Web server based technology, a tool for building Web applications ASP (Not Application Service Provider) A powerful framework that provides dynamic generation of Web pages Facilitates access to information from other sources such as databases Requires Web server that has ASP installed as an extension Combination of HTML and executable codes that allows programming logic to be embedded within a Web page

6 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-5 AIU ITP 665 - Servlets 5 The Original Web Model HTTP REQUEST User’s Browser Web Server HTML Web Page (.htm)

7 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-6 The Dynamic Web Model HTTP REQUEST User’s BrowserWeb Server Engine: reads user’s request ; generates Web page HTML The Web page to be delivered to the client is generated “ on the fly “ as the result of the server-side processing of the “page draft” – the Active Server Page, and the result of this processing will be delivered to the client

8 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-7 7 Why Build Web Pages Dynamically? The Web page is based on data submitted by the user –E.g., results page from search engines and order- confirmation pages at on-line stores The Web page is derived from data that changes frequently –E.g., a weather report or news headlines page The Web page uses information from databases or other server-side sources –E.g., an e-commerce site could use a servlet to build a Web page that lists the current price and availability of each item that is for sale.

9 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-8 8 ASP’s Job – Communicate with Web Client Read explicit data sent by client (form data) Read implicit data sent by client (request headers) Generate the results Send the explicit data back to client (HTML) Send the implicit data to client (status codes and response headers) Can a client sent any data to the server ? Why ?

10 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-9 9 CGI (Common Gateway Interface) : –an extension to Web server application –CGI allowed Web sites to dynamically create Web pages from a program running on a server and typically written in C or a scripting language such as Perl –CGI added functionality to the Web –CGI programs often exhausted memory space on Windows computers –These shortcomings eventually led to Active Server Pages, or ASP from Microsoft, and Servlets and JSP from Sun used now First Tool to make Web Dynamic was : CGI

11 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-10 10 What is an Active Server Page ? a server-side component Runs (being processed by a ASP container (IIS) Hosted on the IIS Web server ASP can be used to Create HTML pages on the fly Perform CGI related task to facilitate HTTP communications between a client and a server Access any business classes at the server Use distributed objects, access databases, email systems, legacy systems Perform many other services

12 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-11 AIU ITP 665 - Servlets 11 Scripting Client Side vs. Server Side Client side scripts are embedded in a Web page and interpreted by the browser Server side codes are embedded in a Web page ( or stand behind it ) and interpreted by the Web server (the browser never sees them) Core language plus environment’s objects provide a powerful tool for creating Web applications

13 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-12 12 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

14 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-13 ASP.NET ASP.NET 3.5 is the latest Web programming technology from Microsoft ASP.NET provides libraries, controls, and programming support for programs that: –Interact with the user –Maintain state –Render controls –Display data –Generate appropriate HTML Write object-oriented, event-driven Web applications using C# and ASP.NET Where is ASP.NET application deployed ?

15 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-14 C# and Web Programming Web Forms are used to create the user interface for Web applications A Web Form displays as a document in a browser You can create documents that display on mobile devices, such as cell phones and PDAs (using the Standard Edition and above) Where is the Web Form hosted ? Where is it processed ?

16 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-15 C# and ASP.NET Each Web Form has two distinct pieces –HTML and instructions needed to render the page –C# code A Web Form generates two files: –.aspx extension for the HTML –.aspx.cs extension for the C# code Holds the logic to respond to events Called the "code behind" file C# code is not compiled into an.exe file, it is compiled into a dynamic link library (dll) file

17 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-16 Web Servers To develop Web applications –Use a remote Web server –Make your local machine a Web server Visual Studio Web Server –Installs automatically with Visual Web Developer or Visual Studio –Simplifies development, testing, and debugging –Use IDE tools to transfer application to an IIS Web server after development to share with others Internet Information Services (IIS)

18 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-17 Web Clients Browsers display pages written in a markup language such as HTML or XHTML Pages may also contain program logic –Script JavaScript, VBScript, JScript –Java applets Programming for a network intranet –Users’ browser is known Programming for the Internet –Test and check output on multiple browsers Internet Explorer, Mozilla FireFox and Opera Is there any difference between HTML and XHTML ?

19 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-18 Web Pages Web pages are stateless –The page does not store any information about its contents from one invocation to the next Techniques for working around the stateless limitation –Storing cookies on the local machine –Sending state information to the server as part of the page's address, called the uniform resource locator (URL) The server can send the state information back with the next version of the page What is a cookie ?

20 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-19 Types of Web Sites Web applications are referred to as Web sites in VS 2008 Four types of Web sites : 1.File System 2.Local IIS 3.FTP site 4.Remote site

21 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-20 File System Web Sites Store Web pages and associated files in any folder on the local computer or on the network Does not expose the computer to security vulnerabilities Does not require administrative rights to create and debug a Web project Runs on Home Edition of Vista or XP

22 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-21 IIS Web Sites IIS on a local computer hosts a Web server that must be secured Requires administrative rights on the computer to create IIS Web projects By default files are stored in C:\inetpub\wwwroot folder –A virtual IIS directory can be created to store a Web site What is a vituall IIS directory ?

23 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-22 Remote Sites and FTP Sites Administrative rights on the host computer must be granted to do development on a remote Web server FTP cannot be used to create a new Web site A previously created FTP Web site can be opened in Visual Studio : – you can do development on a remote server MS Azure platform – have a look what it is …

24 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-23 Creating a Web Site Select New Web Site from the File menu In the New Web Site dialog box, select the template, location, and language Give the Web site a name by appending the name to the location

25 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-24 Web Page Files A new Web site automatically contains one Web page, Default.aspx –Visual representation of the page (HTML tags) A second file, Default.aspx.cs, holds the C# code for the page ASP.NET has a second model for Web applications—single-file model –Stores all HTML, control definitions, and code in one single file The textbook teaches the code-separation model that uses two separate files

26 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-25 Web Forms in the Visual Studio IDE Differences between a Web application and a Windows Forms application –Web Form (page or document) not a Windows Form –Toolbar –List of files in the Solution Explorer –Toolbox has different controls Properties and events different than controls that have a Windows counterpart Views available in the IDE are Design, Source (HTML or ASP.NET) or a Split window How do a Windows Form and Web Form differ ?

27 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-26 Viewing the HTML Code Three tabs at bottom of Web Form –Design –Split Splits the Document window horizontally to see both the design and source –Source Static HTML code

28 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-27 Controls - 1 Several types of controls available for Web Forms –Standard (ASP.NET server controls)—Richest and most powerful controls provided by ASP.NET and.NET framework –Data—Display database data –Validation—Validate user input before it is sent to server –Navigation—Includes the Menu control –Login—Login controls and wizards –WebParts—Change the appearance and behavior of the interface from the browser

29 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-28 Controls - 2 –AJAX Extensions – Provide for faster Web page loading and richer interfaces –HTML – Standard elements that operate only on the client HTML controls pass to and from the server as static text –Others – Depending on version of VS, other sections may be available (i.e. Reporting)

30 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-29 Controls - 3 In Design view, client-side HTML controls and ASP server controls are different Popup DataTips identify the type of control and its ID (Name)

31 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-30 Event Handling Write C# code for events of Web controls in the same way as for Windows controls Events may occur on either the client or server The process of capturing an event, sending it to the server, and executing the required methods is all done automatically Events of Web Forms and controls are different than for Windows Forms –Examples Page.Load versus Form.Load Button control has much shorter list of events for a Web Form versus a Windows From

32 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-31 One more time : Page Files Web application files differ greatly from a Windows application aspx file –Holds specifications for the user interface used by the server to render pages aspx.cs file –Code-behind file for the aspx file

33 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-32 Testing in Other Browsers To test in another browser, in the Solution Explorer: –Right-click on the project name –Select Browse With –Select from browsers installed on the computer Why would you need/like to test in another browser ?

34 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-33 Laying Out Web Forms Factors that will affect the layout of page –Browsers –Screen sizes –Screen resolutions ASP.NET generates appropriate HTML to render the page in various browsers but cannot be aware of the screen size, resolution, or window size on the target machine

35 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-34 Using Tables for Layout HTML tables contain rows and columns and allow control over placement of elements on a Web page Add controls and text to the table cells to align the columns A table is an HTML control, which requires no server-side programming Does it mean that you need to use tables on every page ?

36 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-35 Placing Controls or Text in a Table - 1 Add controls to any table cell or type text in a cell during design time –To refer to the text in a cell at run time, add a label and give it an ID or type text directly into the cell –Merge cells to allow room for a title or a larger image

37 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-36 Placing Controls or Text in a Table - 2 Table borders show at design time but not at run time Hoe to make tables seen at the run time ?

38 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-37 Absolute Positioning Places controls in a specific X and Y position –Controls may not show up if user has set browser window to small size –Controls may overlap if the user has selected a large font size for the browser window Controls can be dragged using the white tab at the top of a selected control Controls remain in the same position relative to the Web page As from the above : does absolute positioning have a value ?

39 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-38 Including Images on Web Pages - 1 Use the Image control to add graphics to a Web page –Concept is similar to the PictureBox on Windows Forms, but the graphic file is connected differently due to the nature of Web applications Each Image control has an ImageUrl property that specifies the location of the graphic file –Best to first copy the graphic into the Web site folder - WHY ? Add an Image control to a cell in a table or directly on a Web page

40 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-39 Including Images on Web Pages - 2 Web page table has three rows and three columns –Image and company title are in first row, textbox is in second row, hyperlink is in last row

41 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-40 Cascading Style Sheets New tools for using styles in Web applications are called Expression Web –Expands, enhances and simplifies using cascading style sheets (CSS) Use CSS to create, modify and apply styles to single elements on a page, an entire page, all pages, or all applications of an organization What do we mean by style ?

42 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-41 Using Styles - 1 Styles are rules that specify page layout, position, font, color, alignment, margins, borders, background and bullet and numbering formats Create and apply new styles within a page Attach an external.css file to apply styles Save styles to an external.css file for use on other pages or Web sites

43 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-42 Using Styles - 2 Styles can be defined in several locations –Web page – inline style For elements that appear only once on a page –style section – page style For elements that may be used in more than one location on a page –external style sheet -.css file For elements that may appear on more than one page or in multiple Web sites How to add external CSS to a Web project ?

44 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-43 Using Styles - 3 “Cascading” refers to the order of precedence of the style rules For example –Style sheet (global) sets font, color, size, alignment –Local (page-defined) style for the color and size takes precedence (font and alignment still in effect from style sheet) –Inline (more local) style for the size takes precedence over local and style sheet (color from local and font and alignment from style sheet remain)

45 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-44 Types of Styles Several new tools are available to define, apply, modify and change the location of styles –Apply Styles window : see Styles menu –Manage Styles window : View -> “Manage Styles” –Use the icons in the CSS Style Types table to identify the various types of styles

46 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-45 Defining Styles Define a new style in the New Style dialog box Choose the category and make settings –For example Font Block –Text-align, text-indent, vertical align List –Bullet and numbering attributes Table –Borders and spacing

47 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-46 Managing Styles In the Manage Styles Window, preview each style –Drag styles from one category to another to change the location of the style definition A style created in the current page can be moved to a.css file to allow its use in other pages In the CSS Properties window see the settings for a given style

48 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-47 Navigating Web Pages ASP.NET provides several techniques to navigate from one Web page to another Easiest form of navigation is to use a HyperLink control

49 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-48 Linear and Hypertext Documents

50 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-49 Using Hyperlinks Add a HyperLink control to allow the user to navigate to another page or another site Set properties of the HyperLink control –Text—Text to display for the user –NavigateUrl—Specify the URL to which to navigate For another Web site, type the Web address (URL) For another page in the application, use the Select URL dialog box and select the page from a list

51 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-50 Adding a Second Web Page Add a new web form to the project Add controls to the new page Add a HyperLink to the Main Page Set the Start Page Run the application, test the links

52 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-51 Transferring Pages in Code At times a hyperlink cannot be used because some other action in code needs to be performed prior to the transfer Transfer to another page in code –Use the Server.Transfer method Server.Transfer (“Offer.aspx”);

53 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-52 Using the Validator Controls - 1 ASP.NET provides several validator controls that can automatically validate input –Add a validator control –Attach it to an input control (such as a text box) –Set the error message to display At run time, when the user inputs data, the error message displays if the validation rule is violated Validator controls run on the client-side How did they do without MS Validator controls ? Can it be done in code ? What language?

54 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-53 Using the Validator Controls - 2 A blank entry passes the validation for each of the controls except the RequiredFieldValidator –To ensure a field is not blank and it passes a range check attach both a RangeValidator and a RequiredFieldValidator to the field Enter a complete message in the ErrorMessage property or set the property to an asterisk

55 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-54 Using the Validator Controls - 3 Validator Controls RequiredFieldValidatorRequires that the user enter something into the field CompareValidatorCompares the value in the field to the value in another control or to a constant. Also can be used to verify that the input value can be converted to the correct data type RangeValidatorRequires that the input value falls in the specified range RegularExpressionValidatorValidates against a regular expression, similar to the mask in a masked text box ValidationSummaryDisplays a summary of all of the messages from the validator controls

56 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-55 Maintaining State Web pages hold static data Each time a page is displayed or redisplayed it is a fresh copy Each time the page is posted back to the server a new copy of the program is loaded Steps must be taken to maintain the state of the page –Otherwise the values of variables and controls on the page will be lost in every postback

57 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-56 Retaining the Contents of Controls ASP.NET can retain and redisplay control contents Web controls have an EnableViewState property –Set to true by default –Indicates to the server to send the control’s contents back with the page

58 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-57 Retaining the Values of Variables - 1 Local variables work the same in a Web or Windows application Class-level variables are lost unless steps are taken to save them Store the value of a class-level variable in a control on a Web page –EnableViewState property holds the value during postback

59 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-58 Retaining the Values of Variables - 2 Set up a control with its Visible property set to false or use the HiddenField control Assign the class-level variable to the invisible control –For a hidden field, use the (string) Value property // Declare a class level variable. private decimal discountTotalDecimal; protected void submitButton_Click(object sender, EventArgs e) { //... Calculations omitted. discountHiddenField.Value = discountTotalDecimal.ToString(); }

60 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-59 Checking for Postback The Page_Load event occurs many times (during each postback) in a Web application IsPostBack property is set to false for an initial page load and true for all page loads following the first Test for IsPostBack == false to perform initialization tasks Test for IsPostBack == true to perform tasks only on postback

61 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-60 Passing Values to a Second Page A HiddenField control maintains the value of a class-level variable for a single page Send information to a second page –Use the Session variable technique to pass data between pages

62 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-61 Using a Session Variable - 1 One instance of the Session object exists for each user of an application –Use to store information about the user on the server –Each time a user accesses an application, a Session object is created with a unique SessionID –Session values are maintained as long as the session exists Sessions can time out, terminate or users can logout Can you get to the same session if you have closed a bropwser and opened it again ?

63 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-62 Using a Session Variable - 2 Drawbacks to session objects –Information is stored on server Large amounts of data for multiple users can bog down the server –Web sites split server loads among several systems (Web Farm) State information might be on a different server than where the postback originates –.NET handles this problem by specifying the name of the machine that stores the session values in the Web.config file

64 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-63 Using a Session Variable - 3 Use the Contents collection of the Session object to store values in code Each item in the collection is a key/value pair –Make up a name (the key) and assign a value Clear all session variables by using the Session.Clear method

65 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-64 AJAX -1 Create interactive Web applications with Asynchronous JavaScript and XML (AJAX) AJAX allows reloading of only a portion of a Web page on each postback –Only the portion of a page that changes is downloaded and rendered Dramatically increases loading speed AJAX is an open and cross-platform technology

66 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-65 AJAX - 2 AJAX pages must include a ScriptManager component (in the toolbox under AJAX Extensions) –Add other controls such as the UpdatePanel A container for other controls –Placing controls inside an UpdatePanel determines which portion of the page updates on a postback The area outside the UpdatePanel remains unchanged

67 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-66 Some Web Acronyms - 1 XML Extensible Markup Language. –This popular tag-based notation is used to define data and their format and transmit the data over the Web. XML is entirely text based, does not follow any one manufacturer’s specifications, and can pass through firewalls. SOAP Simple Object Access Protocol. –An XML-based protocol for exchanging component information among distributed systems of many different types. Since it is based on XML, its messages can pass through network firewalls.

68 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-67 Some Web Acronyms - 2 HTTP HyperText Transfer Protocol. –The protocol used to send and receive Web pages over the Internet using standardized request and response messages. Web Service –Code in classes used to provide middle-tier services over the Internet. WSDL Web Services Description Language. –An XML document using specific syntax that defines how a Web service behaves and how clients interact with the service.

69 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-68 Happy New Year! Happy New Year What do you see here ?

70 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-69 When Communicating Information/Data: Information/data content Language / media of presentation Form of presentation : phone, TV, Web page, chat,... XML : an attempt to filter out “pure information/data” separate information content and its presentation

71 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-70 XML – eXtensible Markup Language What is it? –World Wide Web Consortium (W3C specification) –Describes semantic structure of text documents –Descendant of Standardized General Markup Language (SGML) Complex metalanguage used in technical documentation –Extension of Hypertext Markup Language (HTML)

72 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-71 XML code segment you@yourAddress.com me@myAddress.com Sample of an XML file XML is cool

73 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-72 XML – Characteristics XML is for data –Neutral, generic format –Extensible (can create infinite number of tags) –Flexible –Self documenting (human and machine readable) –Simple, easy to use –Separates style from structure

74 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-73 To build data : XML Hierarchy Document Unit Sub-unit Document Unit Sub-unit All elements must be nested XML can be described in a tree hierarchy Parent Child Sibling

75 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-74 XML Technologies

76 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-75 XSL  XSL Transformations (XSLT)  Is a language for transforming XML documents  XSLT stylesheets  Stylesheets format XML documents  Use XSLT to interact with an XML document  Can format individual or groups of elements within the XML document  A form of XSL that transforms the XML data using processing rules in the XSLT stylesheet

77 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-76 XSL – Universal Presentation of XML Data : How does it work? Binding XML to existing Web pages is fine, but limited way to present XML data; CSS helps, but has its own language; change style – need another CSS Universal and flexible way : create separate XSL file, which defines how to present every element of XML data, merge them together and create HTML page as a result ; both XML and XSL files can be edited in code XML document XSL document XSL processor HTML Page

78 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-77 inventory.xsd

79 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-78 XML ASP/ Database : Hot Stuff Typical Web Application now is a 3-tier architecture: We want to create such an application with XML as a data trasfer media : – RS requested according to SQL from any relational DB to be converted to XML –XML at ASP server saved to a file and sent to a Client –XML at Client modified/created, sent to ASP server, validated/processed, data sent to DB for update Web Client ASP Server DataBase Server XML Recordset

80 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-79 Quiz Explain the differences between the execution of a Windows application and a Web application. Differentiate between the client and the server for a Web application : what is running on a client and what is running at the server ? What is meant by the statement that Web pages are stateless? What are the differences between HTML controls and standard ASP controls? How does event handling differ from that for Windows applications?

81 McGraw-Hill© 2010 The McGraw-Hill Companies, Inc. All rights reserved. 9-80 Quiz ( cont.) Describe the purpose and functionality of AJAX. What is meant by open standards? What is a Session object and how would it be used? What is the purpose of XML? of SOAP?


Download ppt "McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Web Applications."

Similar presentations


Ads by Google