𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

HTML5 Programming for ASP.NET Developers

✍ Scribed by Bipin Joshi


Publisher
Apress
Year
2012
Tongue
English
Leaves
379
Edition
1
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


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.Β  What you’ll learn Use Canvas, Audio and Video, Web Storage, the History API, File API, Web Workers, Web Sockets, Geolocation and more in ASP.NET Illustrates HTML5 feature utilization in both Web Forms and MVC applications Use JavaScript and jQuery to communicate between HTML5 and ASP.NET server side code Learn to use HTML5 in Visual Studio Learn to style web forms and views with CSS3 Develop cross-browser, future-ready web applications Who this book is for Whether you've worked on a few small projects, or been working with ASP.NET and ASP.NET MVC for some time, this book will get you up-and-running with HTML5 so you can make it a part of your daily toolkit.Β  If you are comfortable with creating Web Forms and MVC projects, and you care about staying at the cutting edge of the latest web standards and technologies, this book is for you. Table of Contents Overview of HTML5 and ASP.NET 4.5 Overview of jQuery Working with Audio and Video Drawing with the Canvas Working with Forms and Controls Using History API and Custom Data Attributes Storing Data in Web Storage Developing Offline Web Applications Dealing with Local Files Using the File API Multithreading in Web Pages Using Web Workers Using the Communication API and Web Sockets Finding Location with the Geolocation API Styling Web Forms and Views with CSS3 Appendix A. HTML5 Learning Resources

✦ Table of Contents


Cover......Page 2
Contents at a Glance......Page 3
Contents......Page 367
About the Author......Page 377
About the Technical Reviewer......Page 378
Acknowledgments......Page 379
Web Forms or MVC......Page 4
Structure of This Book......Page 5
Contacting the Author......Page 6
History of HTML5......Page 7
HTML5 Page Structure......Page 8
HTML5 Features of Interest......Page 12
Web Storage......Page 13
Geolocation......Page 14
Checking for HTML5 Support Statically......Page 15
Checking for HTML5 Support Dynamically......Page 17
HTML5 and ASP.NET......Page 19
HTML Formatting......Page 21
IntelliSense and Validations for HTML5 Tags......Page 22
HTML5 Snippets......Page 23
JavaScript IntelliSense......Page 24
Testing a Web Page in a Specific browserTesting......Page 25
A Simple ASP.NET Web Forms–based Web Application Using HTML5......Page 26
A Simple ASP.NET MVC-Based Web Site Using HTML5......Page 32
Summary......Page 39
What Is jQuery?......Page 41
Downloading and Referring to jQuery......Page 42
Event Handling......Page 45
jQuery Selectors......Page 50
Selecting Elements Based on ID, Tag Name, and CSS Class......Page 51
Selecting Elements Based on Their Attribute Value......Page 54
Selecting Form Elements......Page 57
Modifying the DOM Using jQuery......Page 60
jQuery Ajax Techniques......Page 61
Using the jQuery $.ajax() Method in a Web Forms Application......Page 63
Using the jQuery $.ajax() Method in an MVC Application......Page 66
Summary......Page 67
Embedding Media Files Using the Tag......Page 68
Embedding Silverlight Video Files......Page 69
Playing Audio......Page 70
Playing Video......Page 72
Supported Audio and Video Formats......Page 74
Supporting Multiple Media Formats......Page 77
Flash or Silverlight Fallback......Page 78
Programming with the Audio and Video APIs......Page 79
Creating a Custom Video Player Using the Video API......Page 80
HTML5 Markup......Page 81
SQL Server Database and Entity Framework Data Model......Page 82
Fetching the Video Playlist......Page 83
Playing, Pausing, and Stopping a Video......Page 84
Displaying Duration and Progress......Page 85
Summary......Page 87
The Element......Page 88
Drawing on the Canvas......Page 89
Drawing Lines......Page 90
Changing the Line Width and Cap......Page 91
A Quick Introduction to Radians......Page 93
Drawing an Arc Using the arc() Method......Page 94
Drawing Paths......Page 97
Drawing Text......Page 99
Drawing Images......Page 101
Shadows......Page 103
Transparency......Page 105
Gradient Filling......Page 106
Pattern Filling......Page 108
Saving the Canvas State......Page 109
Using the save() and restore() Methods......Page 110
Using the toDataURL() Method......Page 111
Saving the Canvas Drawing in SQL Server......Page 112
Saving the Canvas Drawing as an Image File on the Server......Page 113
Creating Pie Charts Using Canvas Drawing Techniques......Page 115
SQL Server Database......Page 116
MVC Controller......Page 117
Adding Chart Data......Page 118
Drawing a Pie Chart......Page 119
Saving a Pie Chart......Page 121
Summary......Page 123
Understanding HTML Forms in ASP.NET......Page 124
The
Element in ASP.NET Web Forms......Page 125
The Element in ASP.NET MVC......Page 126
HTML5 Controls......Page 127
Using HTML5-Specific Input Types......Page 128
E-mail Addresses......Page 129
Numbers and Telephone Numbers......Page 130
Dates and Times......Page 132
Colors......Page 134
Using the New Input Types in Web Forms......Page 135
Using the New Input Types in MVC Views......Page 136
Pattern-Matching Using Regular Expressions......Page 137
Turning HTML5 Validations On and Off......Page 138
Performing Custom Validations......Page 139
HTML5 Input Types and ASP.NET Validation Techniques......Page 140
HTML5 Input Types and Validation Controls......Page 141
HTML5 Input Types and Server-Side Validations in an MVC Application......Page 142
Customizing Validation Messages......Page 144
Customizing the Appearance of an Input Field Using CSS Pseudo-Classes......Page 145
Customizing Validation Messages Through Code......Page 146
Displaying Help Text Using Placeholders......Page 148
Turning Off Autocomplete......Page 149
Setting a Form’s Action and Method......Page 150
Designing an Employee Data Form......Page 151
Using HTML5 Input Types and Related Attributes......Page 152
Taking Care of Date Formatting......Page 154
Writing the CRUD Methods......Page 155
jQuery Code......Page 157
CSS Pseudo-Classes......Page 159
Designing a User Registration Form......Page 160
Entity Framework Data Model and Data Annotations......Page 162
User Controller......Page 163
Displaying the User Registration Form in an MVC View......Page 165
Checking for Duplicate Display Names and E-mail Addresses......Page 166
Handling the invalid Event and Displaying Validation Errors......Page 167
Summary......Page 169
The History Object......Page 170
Understanding the History-Tracking Problem......Page 173
Using Hash Fragment in URLs......Page 176
Understanding the History API......Page 177
Custom Data Attributes......Page 181
Overview of Custom Data Attributes......Page 182
Accessing Custom Data Attributes Using jQuery......Page 183
Using Custom Data Attributes to Emit Validation Messages......Page 184
Summary......Page 187
Overview of Web Storage......Page 188
Session Storage and Local Storage Objects......Page 189
Using the sessionStorage and localStorage Objects......Page 190
Storing Numbers, Dates, and Objects......Page 191
Session Storage and Local Storage Events......Page 194
Clearing Web Storage Manually......Page 195
An Example of Using Local Storage in a Survey Form......Page 196
Passing Data as Hidden Form Field......Page 205
Summary......Page 206
When to Use Offline Applications......Page 207
HTTP Caching and Offline Applications......Page 208
Building an Offline Application......Page 209
The CACHE Section of the Cache Manifest......Page 211
The NETWORK Section of the Cache Manifest......Page 212
Referring to the Cache Manifest in Web Forms and Views......Page 213
Configuring IIS to Recognize the Cache Manifest File......Page 215
Testing an Offline Application......Page 216
Going Online Using Ajax......Page 217
Updating an Offline Application......Page 218
Offline Application Events......Page 220
ASP.NET MVC Example: the Survey Application Revisited......Page 222
Creating a Cache Manifest File......Page 223
Getting the Questions and Choices......Page 224
Checking for a Network Connection......Page 225
Summary......Page 226
Understanding the File API......Page 227
FileList Object......Page 228
FileReader Object......Page 229
Using a File Field to Select Files......Page 230
Using a Custom Button to Select Files......Page 233
Working with Drag-and-Drop......Page 235
Drag-and-Drop Events......Page 236
Implementing Drag-and-Drop: A Shopping Cart......Page 237
Product Catalog and Shopping Cart......Page 238
Handling Drag-and-Drop Events......Page 239
Dragging and Dropping Files......Page 244
Reading Files and Displaying File Information......Page 245
Uploading Files to the Server......Page 250
Using the File API in ASP.NET MVC......Page 251
Summary......Page 257
Overview of Multithreading in Web Pages......Page 258
What Web Workers Can Access and What They Can’t......Page 261
Using Web Workers......Page 262
Importing External Script Files......Page 264
Handling Errors......Page 265
Monitoring Web Workers During Development......Page 266
Using Shared Web Workers......Page 267
Communicating With the Server......Page 270
Using Web Workers That Require Server-side Data......Page 271
Order History View......Page 272
Creating a Web Worker......Page 273
Event Handlers for message and error Events......Page 274
Code Running in the Web Worker......Page 275
GetOrders() Action Method......Page 276
Summary......Page 277
Understanding Cross-Domain Communication......Page 279
Cross-Document Messaging......Page 280
Cross-Origin Resource Sharing (CORS)......Page 281
Using postMessage with