Asp.net web page elements can be shared in multiple languages

Source: Internet
Author: User

For some systems developed, it is often required to support multiple languages (such as Japanese and English). In the past, most of the practices were to create a resource file,

Set each label, button, and other title text in various languages in advance,

Display the corresponding text in the program based on the selected language.

The disadvantage of doing so is that every time you modify or add a control, the program developers need to deliberately do multiple language mappings,

If you want to change the description of certain titles, you also need to change the resource file and replace it with the program release directory.

After investigation and experiment, I finally figured out a way to better address this problem:

On each web page, set a button (for example, "set") that can only be viewed with the highest level of management permissions "),

To set the fixed titles on the screen. Click this button to display all

Controls (such as Label, button, gridview, linkbutton, etc.) are displayed on a small page in various languages for users to set,

Save it to DB. When you open the page next time, follow the title of the page control in the initial stage of the content set by DB.

End users are free to set and do not need to be constantly modified by developers.

The screen effect is as follows:

Click "set"

The following is an example of code that indicates that controls (TextBox, DropDownList, and so on) on the page are not available:
Copy codeThe Code is as follows:
Public Shared Sub LoopingControlsDisabled (ByVal oControl As Control)
Dim frmCtrl As Control
Dim btn As Button
For Each frmCtrl In oControl. Controls
If TypeOf frmCtrl Is TextBox Then
DirectCast (frmCtrl, TextBox). Enabled = False
End If
If TypeOf frmCtrl Is DropDownList Then
DirectCast (frmCtrl, DropDownList). Enabled = False
End If
If TypeOf frmCtrl Is CheckBox Then
DirectCast (frmCtrl, CheckBox). Enabled = False
End If
If TypeOf frmCtrl Is RadioButton Then
DirectCast (frmCtrl, RadioButton). Enabled = False
End If
If TypeOf frmCtrl Is FileUpload Then
DirectCast (frmCtrl, FileUpload). Enabled = False
End If
If TypeOf frmCtrl Is Button Then
Btn = DirectCast (frmCtrl, Button)
'If btn. Text. Equals ("close") OrElse btn. ID. Equals ("btnClose") Then
If btn. ID. Equals ("btnClose") Then
'Only the close button is available
Btn. Enabled = True
Else
Btn. Enabled = False
End If
End If
If frmCtrl. HasControls Then
LoopingControlsDisabled (frmCtrl)
End If
Next
End Sub

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.