Upload
virgil-blake
View
235
Download
0
Tags:
Embed Size (px)
Citation preview
ASP.NET 2.0, Third Edition 4
The Fundamentals of Tags and Attributes
• There are two basic parts to an HTML tag: the opening tag and the closing tag; they are always enclosed within angle brackets (<>).– <b>Course Technology</b>– The <b> tag tells the browser to bold the subsequent text until
the browser finds a closing tag </b>
• These attributes provide a means of altering the tag in some way
• The id attribute is used to provide a unique identifier for the tag within that document
• Standards are maintained by the World Wide Web Consortium (W3C)
ASP.NET 2.0, Third Edition 5
HTML Structure
All tags nested within the (html></html>) tags
Heading Section identified by (<head></head>) – Title tags (<title></title>) identify the page name in the title bar,
in the history list, and in the favorites list within the browser application
– Style sheets within the <style> tags or external linked style sheets <link> format the contents of the page
<link type="text/css" href="ch_sample1.css" /> – Meta tag (<meta />) can be used to force the browser to
identify keywords and other global values, reload the page, and identify the character encoding scheme
<meta name="keywords" content="Course Technology, ASP.NET " />
ASP.NET 2.0, Third Edition 6
HTML Structure (continued)
Body Section identified by (<body></body >) – The bgColor attribute is used to change the color of the
background
<body bgColor="black">
– Color value can also be identified by the hexadecimal number associated with the color
<body bgcolor= "#000000" text= "#33CC00" background= "images/disk.gif" link= "#FFFFFF" vlink= "#FFFF66“ alink= "#FF0066">
ASP.NET 2.0, Third Edition 8
Tags that Contain or Format Text
• Paragraph tags (<p></p>) include carriage return
• Blockquote tags (<blockquote></blockquote>) – indent text
• Line break tag (<br />) includes carriage return; no content
• Span tags (<span></span>) – inline
• Div tags (<div></div>) – block tag; includes carriage return
• Bold (<b>), italic (<i>), and underline (<u>)
• Horizontal line (</hr>)
• Boolean attributes – no value assigned<hr size="10" noshade= "noshade" />
ASP.NET 2.0, Third Edition 9
Tags for Elements Other than Pure Text
• Table tags (<table></table>) – Attributes set table width, height, border, background color and
image
• Table row tags (<tr></tr>) define the row
• Table cell tags (<td></td>) define the cell
• Table heading cell tags (<th></th>) display contents bolded
• Table heading, body, footer tags (<thead></thead>, <tbody></tbody>, <tfoot></tfoot>) identify table header, body, and footer sections, respectively
• Caption tag (<caption></caption>)
• Colgroup tags (<colgroup></colgroup>) – parent tags for column tags (<col></col>)
ASP.NET 2.0, Third Edition 10
Tags for Elements Other than Pure Text (continued)
• Form tags (<form></form>) contain elements, such as text boxes, radio buttons, check boxes, and drop-down lists
• Unordered list tags (<ul></ul) • Ordered list tags (<ol></ol)
– List item tags (<li></li>) • Image tag (<img/>) – graphic image • Anchor tags (<a></a>) – creates a hyperlink
<a href="url/pagename.htm" target="_blank"> Displayed content goes here.</a>
– Bookmarks specify a location within a web page<a name = "top"> <a id = "top">
• Named markup represents a character entity within the web page– Ampersand (&) represented by &– Apostrophe (‘) represented by '
ASP.NET 2.0, Third Edition 12
Introduction to XML
• XML Standards – Extensible Markup Language (XML) – XML Document Object Model (DOM) – a standard
language-neutral interface for manipulating XML– XML parser – to read & display XML documents
ASP.NET 2.0, Third Edition 14
XML Rules
• Well-formed documents follow XML standards – All tags must be nested within the root node– Case sensitive– Must nest in specific order– Container element is an element in which other
elements can nest– XML declaration specifies the version of XML
• <?xml version="1.0" encoding="utf-8" ?>
– Characters not supported (<>’ “ &)
ASP.NET 2.0, Third Edition 16
Markup Validation of XML Documents
• XML documents identify a set of rules, or namespace, associated with the document called a schema
• Schemas define the structure, content, and semantics of XML documents written in:– Document type definition (DTD)
• Doctype declaration
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> – XML schema define structure elements as a typed dataset
• xmlns attribute of the root node identifies the XML schema
<html xmlns="http://www.w3.org/1999/xhtml">
ASP.NET 2.0, Third Edition 20
Web Site Accessibility
• Americans with Disabilities Act (ADA), California Online Privacy Protection Act (COPPA), Data Protection Act, Disability Discrimination Act– U.S. government's Section 508 – UK's Disability Discrimination Act
• W3C Web Accessibility Initiative (WAI) provides Web Content Accessibility Guidelines (WCAG) – Blindness, low vision, color deficit or distortions,
deafness and hearing loss, learning disabilities, paralysis, and photo sensitive epilepsy
• Bobby – online accessibility validation
ASP.NET 2.0, Third Edition 21
Introduction to ASP.NET Server Programming
• Client-server programming – client applications to communicate with server applications
• Dynamic web application interacts with application in ways that change the appearance or content – Shopping carts, membership databases, online
catalogs, personalized web sites
• Limitations of client-side scripting alone are browser dependency and security
ASP.NET 2.0, Third Edition 23
Processing ASP.NET Applications (continued)
• Web Forms are web pages identified with the file extension .aspx
• Assembly contains language- and computer-independent representation of code called Microsoft Intermediate Language (MSIL)
• ASP.NET engine dynamically compiles the assembly and translates into computer-specific instructions
• HTML output sent back to the browser
• Namespaces are a hierarchical way to organize base classes System.Web.UI.HTMLControl – (HTMLControl class) properties and methods common to all
HTML server controls
ASP.NET 2.0, Third Edition 25
Server Controls (continued)
• Server controls generate HTML tags, JavaScript, and Dynamic HTML (DHTML) output compatible with the browser
• Label, text box, and button controls generate a hidden input field named __EVENTVALIDATION
• __VIEWSTATE and __EVENTVALIDATION contain information about the controls
• __doPostBack JavaScript passes the control id and arguments with __EVENTTARGET and __EVENTARGUMENT hidden fields
ASP.NET 2.0, Third Edition 27
HTML Tags and HTML Controls
• HTML Server controls– Transform the HTML tag into HTML Server control
• Runat property is set to server; set ID property
<input id="Text1" type="text" runat="server"/>
– Properties assigned values in the Properties window, opening tag, or server programming code
– Generate HTML sent to the browser – Create server-side programs that interact with the
controls with no JavaScript required
ASP.NET 2.0, Third Edition 28
Web Controls
• Web Server controls– Prefix asp:control name
<asp:Button ID="Button1" runat="server" Text="Show the message" />
– Different properties than HTML controlsMessage1.InnerHTML = "Product 1"
Message2.Text = "Product 2"
– Set properties in markup or programmaticallyMyControl.BorderColor = System.Drawing.Color.Green
ASP.NET 2.0, Third Edition 30
Using the Postback Process
• Maintaining state – maintain information across browser requests
• Postback – posting of data back into the form • __VIEWSTATE encoded string contains
information required to maintain the form data across multiple page requests
• Enable Secure Sockets Layer (SSL) protocol using https://
• Set the EnableViewState property within @Page directive<%@ Page EnableViewState="false" %>
ASP.NET 2.0, Third Edition 31
Summary• HTML is a markup language that uses tags to identify how to
format and present the content; web pages created with HTML can end in .htm or .html
• Two parts to a web page are the head and body• Forms collect information from the visitor; form elements include
text boxes, check boxes, and drop-down lists• Create HTML code in HTML view, or Design view
ASP.NET 2.0, Third Edition 32
Summary (continued)
• Web Forms build dynamic web pages using new server-side controls that end in .aspx
• Enhance the user interface and increase interactivity • HTML controls runat attribute set to server• Server controls create output for the browser• XHTML is a version of HTML that is XML-compliant• XML files formatted with CSS or XSLT stylesheets• XML files must be well formed
– One root element in any XML document – Tags such as <br> must be closed in the first tag <br /> or
include a closing tag <br></br>– Elements are case sensitive– All elements have an opening and closing tag
ASP.NET 2.0, Third Edition 33
Summary (continued)
• XML schema is a set of rules to define document format and structure of the data
• Validation tools are used to verify that the XML code is compliant with the schema
• Web Content Accessibility Guidelines (WCAG) address broad accessibility issues related to web access and standards
• Namespaces are a hierarchical way to organize classes within the assemblies
• Dynamic Help and IntelliSense help programmers prevent syntax errors