08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 14 ■ JAVASCRIPT PROGRAMMING WITH <strong>ASP</strong>.<strong>NET</strong> <strong>AJAX</strong> 349<br />

Now if you use localeFormat <strong>and</strong> pass it a format string, the output will be formatted<br />

according to the current locale. For example, d gives MM/DD/YYYY in the United States<br />

<strong>and</strong> DD/MM/YYYY in the United Kingdom.<br />

var a = myDate.localeFormat("d");<br />

Parsing a Value into a Date<br />

The parseLocale function allows you to create a locale-specific string by specifying the<br />

format. It takes two parameters: the date value <strong>and</strong> the format that you want the date to<br />

be formatted in.<br />

var a = Date.parseLocale('2007-12-1', 'yyyy-mm-dd');<br />

Error Type Extensions<br />

These provide extensions to the JavaScript Error objects that provide exception details<br />

<strong>and</strong> different application compilation modes. The extension contains a number of error<br />

types that you can raise:<br />

Error.argument: This lets you create an Error object that represents an exception in<br />

the arguments that you received in a function.<br />

Error.argumentNum: This allows you to create an Error object that represents a null<br />

exception.<br />

Error.argumentOutOfRange: This allows you to create an Error object that represents<br />

that an argument was out of the desired range.<br />

Error.argumentType: This allows you to create an error that represents a type exception<br />

error.<br />

Error.argumentUndefined: This allows you to create an error that represents that an<br />

argument is undefined.<br />

Error.create: This allows you to create a free-format error with specifiable error text.<br />

Error.invalidOperation: This allows you to create an error that declares that an<br />

invalidOperation was hit.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!