Skip to main content
Top

2012 | Book

HTML5 Programming for ASP.NET Developers

insite
SEARCH

About this book

HTML5 Programming for ASP.NET Developers teaches you to harness the power and flexibility of HTML5 in your ASP.NET Web Forms and ASP.NET MVC applications. Focusing on the programmable features of HTML5 that will be most useful to you as an ASP.NET developer, this book will take you straight to the heart of what you can get out of this new technology.

HTML5 is an emerging web standard that has received a great deal of attention from browser companies and the developer community, encompassing HTML, JavaScript enhancements and CSS3 specifications. But HTML5 isn't just about markup. A major part of HTML5 is its programmable features and APIs, which make up the core of this book.

HTML5 Programming for ASP.NET Developers will show you how to:

Add interactivity and media to your sites using the Canvas and Audio and Video APIs. Make your web applications work offline, understand client side storage options using web storage, and work with local files using the File API. Use the Communication API and Web Sockets for easier communication between server and client.

Other topics include multithreading with Web Workers, understanding the new input types, using Geolocation, and enhancing your web forms and views with CSS3. All major browsers already support HTML5 to varying degrees and are aggressively working to provide full-fledged standardized support. Start using HTML5 in your projects today, and build future-ready web applications that take advantage of the exciting features that HTML5 has to offer.

Table of Contents

Frontmatter
CHAPTER 1. Overview of HTML5 and ASP.NET 4.5
Abstract
Until recently, ASP.NET developers didn’t need to bother much about the version number of HTML—and now suddenly everybody is talking about HTML5! That’s the kind of impact the evolved HTML standards will have on the web pages we develop now and in the future. Of course, the old functionality provided by traditional HTML (such as HTML 4.01) isn’t going away. The previous version is an integral part of HTML5, but the new improvements offered by HTML5 are appealing to any ASP.NET developer.
Bipin Joshi
CHAPTER 2. Overview of jQuery
Abstract
To take advantage of many HTML5 features, you need to use client-side scripting techniques. Although you can use JavaScript to accomplish this task, using jQuery is easier and more beneficial. If you’re developing a modern web application, chances are you’re already using jQuery for your client-side scripting needs. So, sticking with jQuery for programming HTML5 features will make your code more readable, consistent, and manageable. In addition, jQuery offers many benefits over plain JavaScript (selectors and Ajax calls, for example, as discussed in this chapter) that you can use in your client-side code. Some HTML5 features require you to send data from the client to the server. This data transfer can be done effectively through Ajax requests to the server, and jQuery offers rich support for making Ajax requests. All the benefits mentioned here make jQuery an ideal choice for programming HTML5 features.
Bipin Joshi
CHAPTER 3. Working with Audio and Video
Abstract
Web sites built more than a decade ago were mainly collections of static HTML pages. Then came JavaScript, and web pages became more interactive and animated. However, media-rich web sites were still in their infancy. Over the years the situation has changed to a great extent. Web sites supporting audio and video aren’t at all uncommon. Video-sharing web sites such as YouTube have become immensely popular. To add to this media madness, social networking web sites such as Facebook and Google+ let you share videos with just a click of your mouse. The bottom line is that media-rich web sites will become more and more common in the years to come.
Bipin Joshi
CHAPTER 4. Drawing with the Canvas
Abstract
One of the reasons for the popularity of the Web is the graphical user interface offered to end users. Images, animations, fonts, and other interactive effects make a web site appealing from an end user’s perspective. However, one limitation that web site developers may have encountered when developing pre-HTML5 web applications was drawing graphics in the browser using client-side capabilities. ASP.NET developers have been using the System.Drawing namespace to generate graphics on the fly on the server and then send them to the client, but there is no native support for drawing graphics in the browser window.
Bipin Joshi
CHAPTER 5. Working with Forms and Controls
Abstract
One of the key areas where ASP.NET shines is developing data-driven web applications. Most ASP.NET web applications are more than collections of HTML pages. They involve a variety of database tasks ranging from simple listings of records to complex database operations. These tasks often include accepting user input, performing validation on the data entered by the user, processing the data on the server, and finally saving it in a data store.
Bipin Joshi
CHAPTER 6. Using History API and Custom Data Attributes
Abstract
Whenever you navigate between various pages of your web application, the browser maintains a history of the pages you visited. You can navigate through the history using the browser’s back and forward buttons. The same history is accessible to the JavaScript code through the History object. Although the History object isn’t a new addition in HTML5, there are some enhancements to it that are worth knowing about. Especially in Ajax-driven applications, the new History API can prove to be very useful. An Ajax-driven application often changes the web page content without generating unique URLs for each different piece of content rendered in the page. This not only causes mismatches between the bookmarked URLs and the actual content but also makes content difficult for search engines to track. The History API provides a small object model as compared to other HTML5 APIs, but the functionality offered is often desirable when web applications need to synchronize the URL shown in the browser address bar and the page content.
Bipin Joshi
CHAPTER 7. Storing Data in Web Storage
Abstract
Most of the web sites developed today deal with data in one form or another. Naturally, this application data needs some sort of storage mechanism. As far as the server is concerned, there are sophisticated database engines such as SQL Server. However, storing data on the client side can be tricky. Traditionally, developers used cookies to persist data on the client side, but cookies suffer from their own limitations. To provide a streamlined data-storage mechanism at the client side, HTML5 provides web storage. This chapter examines what web storage is along with situations where it can be used. Specifically, you learn the following:
  • What is web storage?
  • Flavors of web storage
  • Storing items in, retrieving them from, and removing them from web storage
  • Storing non-string data in web storage
  • Passing data from web storage to the server for further processing
Bipin Joshi
CHAPTER 8. Developing Offline Web Applications
Abstract
Web applications are often looked on as wired applications that are connected to the network at all times. This “always on” nature of web applications is one of the reasons for their popularity and rapid growth. In today’s Internet age, when network connectivity isn’t a big deal, this characteristic of web applications doesn’t pose a problem in most scenarios. However, sometimes you can’t guarantee network connectivity. What should users of your application do then? Wouldn’t it be nice if they could use your web application even in the absence of network connectivity? That is precisely what HTML5 offline web applications offer.
Bipin Joshi
CHAPTER 9. Dealing with Local Files Using the File API
Abstract
It’s a well-known fact that for the sake of security and privacy, browsers don’t allow web applications to tamper with the local file system. Local files are used in a web application only when the user decides to upload them to the server using the HTML <input> element of type file. The title of this chapter may surprise you at first, because the term File API gives the impression of being a full-blown file-system manipulation object model like the System.IO namespace of .NET Framework. Obviously, the people behind HTML5 are aware of the security issues such an object model can create. So, the File API is essentially a cut-down version of a file-handling system in which files can only be read and can’t be modified or deleted. Additionally, the File API can’t read any random file on the machine. File(s) to be read must be explicitly supplied by the user. Thus, the File API is a safe way to read and optionally upload local files with user consent.
Bipin Joshi
CHAPTER 10. Multithreading in Web Pages Using Web Workers
Abstract
The creators of JavaScript invented the language as an aid to developing interactive web pages. HTML markup by itself is purely static in nature and lacks any programming abilities. JavaScript was introduced to compensate for this lack of programmability. Considering the needs that were felt that time, JavaScript was created as a simple, lightweight, easy-to-use language.
Bipin Joshi
CHAPTER 11. Using the Communication API and Web Sockets
Abstract
So far in this book, you’ve learned about HTML5 features that require no server-side communication. Although you used some techniques such as jQuery $.ajax() to send and receive data between the client and the server, doing so wasn’t an integral part of the HTML5 feature being discussed. In this chapter, however, you learn about a few HTML5 features that are specifically designed to facilitate communication between the client browser and the server. Using these features, you can pass data to and from web pages from the same web application or from different applications. Additionally, some of these techniques provide one-way (client to server) communication, and others provide two-way (client to server and server to client) communication. Specifically, you learn about the following:
  • Cross-document messaging and Cross-Origin Resource Sharing (CORS)
  • Using the postMessage API to send data to documents from different web application
  • Using the new XMLHttpRequest Level 2 features to make GET and POST requests
  • Notifying the client using server-sent events
  • Performing two-way communication using Web Sockets
Bipin Joshi
CHAPTER 12. Finding Location with the Geolocation API
Abstract
Most of today’s web applications don’t care where you’re accessing them from. Regardless of your geographical location, they present the same content in the browser. However, if you make such information available to web applications, they can make innovative use of it. For example, a social networking web application can suggest friends who are in the same locality as you. User-location information can also be used in job portals to suggest jobs near the user’s geographical location.
Bipin Joshi
CHAPTER 13. Styling Web Forms and Views with CSS3
Abstract
As an ASP.NET developer wishing to harness the power of HTML5, your primary area of interest is the programmable features of HTML5. However, as a part of developing real-world professional web applications, you also need to look into the styling aspects of those web applications. When it comes to styling web forms and views, Cascading Style Sheets (CSS) is the de facto standard, and CSS3 adds many enhancements that make styling even better. CSS3 isn’t part of HTML5, but they’re evolving together and complement each other well.
Bipin Joshi
Backmatter
Metadata
Title
HTML5 Programming for ASP.NET Developers
Author
Bipin Joshi
Copyright Year
2012
Publisher
Apress
Electronic ISBN
978-1-4302-4720-3
Print ISBN
978-1-4302-4719-7
DOI
https://doi.org/10.1007/978-1-4302-4720-3

Premium Partner