Anda di halaman 1dari 20

AJAX & Globalization

Globalization in ASP.NET

International applications should be customizable according to the preferences of users belonging to different nations, cultures, or regions. User preference refers to the language, currency, and date formats. The structure of an internationalized application is divided into two blocks: Code block Data block

Globalization in ASP.NET (Contd.)

Internationalization includes three phases: Globalization: Involves writing the executable code for an application in such a way that makes it culture-neutral and language-neutral. Localizability: An application that has been globalized must be tested to ensure that its executable code is independent of the culture and language-specific data. Localization: Involves the customization of an application for a specific locale. One major task in this phase is the translation of resources identified during the globalization phase.

Globalization in ASP.NET (Contd.)

The three phases of internationalization are shown in this figure:

Globalization in ASP.NET (Contd.)



The System.Gloablization namespace provides different classes that enable you to determine locale-specific information, such as the language and country of an application at run time. You can implement globalization by: Using the CultureInfo Class: The following are some of the commonly used properties of the CultureInfo class:

CurrentCulture CurrentUICulture DisplayName EnglishName Name LCID

Globalization in ASP.NET (Contd.)

Character Encoding Encoding is the scheme for representing characters in a numeric format. The characters from different languages are grouped into a set called a character set. There are two very commonly used character sets. They are: American National Standards Institute (ANSI): Includes 256 characters and punctuations. In ANSI, every character is represented using one byte (8-bit). Unicode: In Unicode, every character is represented using 2 bytes (16-bit).

Globalization in ASP.NET (Contd.)

Mirroring While creating internationalized Web applications, you need to consider the fact that there are languages that are read from the right to the left. In case of Right-To-Left (RTL) languages, the alignment of text and the layout of different UI components, such as menus and buttons, are reverse of the normal flow. Mirroring is the transformation of coordinates. Validating Nonlatin User Input A language that does not follow the Latin script is called a nonlatin language. The Char structure exposes some validation methods that can be used to determine the category of a nonlatin alphabet input in the same way as a Latin alphabet input.

Globalization in ASP.NET (Contd.)

Working With Resources A resource is any non-executable data that is logically deployed with an application. A separate resource file should be created for each culture for which the application is to be customized. You can use the Resource File Generator (ResGen.exe) command prompt utility to convert a resource file in the text format into the binary format. The output of creating resource-only assemblies will be a DLL file, which will contain all the resource files you added. Satellite assemblies are resource-only assemblies that contain only culture-specific resources. The System.Resources namespace provides different classes, which enable you to retrieve values from resource files.
8

Globalization in ASP.NET (Contd.)

Configuring a Web Application for Globalization: In ASP.NET, you can use the Web.config file to configure an application for globalization. The <globalization> tag has the following attributes: requestEncoding responseEncoding fileEncoding culture UiCulture

Ajax.NET
1st AJAX library for Microsoft .NET

10

Ajax.NET How it works


Add reference ajax.dll to your project Modify your web.config to configure IHttpHandler for Ajax.NET requests Write your methods in C#/VB.NET and add the attribute [AjaxMethod] Call Class1.Method1(param1, param2, callback, context); from client-side JavaScript

11

Ajax.NET Key Benefits (1)


Methods only get attribute, no need to implement interface or inherit from class
[AjaxMethod] public int GetAge(string username){}

Source-code doesnt change if you want to use the method in server-side code
DemoMethods dm = new DemoMethods(); int age = dm.GetAge(michael);

WebServices can be used without code change:


<script type= text/javascript src=servie1.asmx?AJAX></script>

12

Ajax.NET Key Benefits (2)


Client-side JavaScript will get real objects from Ajax.NET calls using JSON
<script type=text/javascript> function test_callback(res) { alert(res.value.FirstName + + res.value.FamilyName); } </script>

DataSet, DataTable, DataRow, ArrayList, Array, DateTime, TimeSpan, Create your own IAjaxObjectConverters

13

Ajax.NET Key Benefits (3)


Cache requests (CacheDurationTimeSpan) Access SessionState objects using HttpContext.Current.Session[] Context support for callback method Unicode support without use of XML parser Use Ajax.NET to retreive events instead of polling

14

Ajax.NET Ideas (1)


ViewState access (read/update) in Ajax.NET methods Access controls of page if Ajax.NET method is placed in WebForm.
The first idea was to use Ajax.NET methods only in seperate classes.

WebControls using Ajax.NET:


LiveSearch, LiveTree, LiveMenue, LiveTicker, LiveTable,

15

Ajax.NET Ideas (2)


DataBinding/DataGrid using Ajax.NET, every click on next page will call Ajax.NET method. asp:DataGrid tags will be parsed by client-side JavaScript FileUpload control with events:
OnUploaded, OnUploading (ProgressBar, bytes, percent,), OnError

DotNetNuke, SharePoint support

16

Ajax.NET Ideas (3)


QueryString from the original requested page Use any object as Ajax.NET method argument without creating an IAjaxObjectConverter Configure how an Image will be returned
ImageFormat, JPEG Compression,

17

Ajax.NET Ideas (4)


Call Ajax.NET methods from different servers and load balancing
Internet Explorer will not allow posting data to different domains by default.

Disable/enable cache from the client-side More Enumeration support for client-side, export enumerations to compare values
if(res.value == MyEnumType.Manager){}

18

Ajax.NET Ideas (5)

A more complex event handler for JavaScript events from server-side code
Server-side code: Watcher watcher = new Watcher(); watcher.Changed += new AjaxWatchEventHandler(); Client-side code: ajax.OnWatchEvent = function(){}

Server.TransferSilent/RedirectSilent
used for web sites (instead of web applications) to get rid of the postback and full page reload

19

Ajax.NET Ideas (6)


Create HTML files that represent different Ajax.NET calls (keyword Google Sitemap).
These files should automatic redirect to the Ajax.NET page.

20

Anda mungkin juga menyukai