ASP.NET Web Controls in Bidirectional Applications

You can use HTML and ASP.NET server controls with bidirectional text. Typically, text directionality is set using the dir attribute of the html element in a page, because text direction also affects the scroll bar position in some browsers. For more information, go to the World Wide Web Consortium (W3C) Web site and see "Language Information and Text Direction." Additionally, you can configure ASP.NET server controls to use bidirectional text.

Control Reading Order

By default, controls inherit the reading order from the page they are in. Additionally, you can set the reading order for individual controls, as follows.

  • HTML server controls expose a Dir property that you can set in the Properties dialog box.

  • ASP.NET server controls expose a Direction property that you can set in the Properties dialog box.

For detailed information, see How to: Display Right-to-Left Text Using HTML Tags for Globalization.

Displaying Numerals

The DropDownList and ListBox controls always display Latin numerals, even if the regional settings indicate a different locale.

Validation Controls

Mostly, the ASP.NET server controls that are used for validation support bidirectional languages. Note the following:

  • The validation controls do not ignore diacritics for the Arabic language.

  • In the RegularExpressionValidator control, add the \W specifier to support characters in bidirectional languages.

    For example, the following regular expression is used to validate an e-mail expression:

    \w+([-+.]\w)*@\w+([-.]\w)*\.\w+([-.]\w)*
    

    The corresponding regular expression for multilingual text would be as follows:

    (\w+|\W)([-+.](\w+|\W))*@(\w+|\W)([-.](\w+|\W))*\.(\w+|\W)([-.](\w+|\W))*
    

    For detailed information about regular expressions, see .NET Framework Regular Expressions.

For information about validating user input, see Validation ASP.NET Controls.

Clipping

Under some circumstances, controls might clip text when the controls are set to right-to-left reading order. You can change this by padding the display for the control with a style setting such as the following:

style="PADDING-RIGHT: 5px"

See Also

Other Resources

ASP.NET Globalization and Localization