开发者

Localization of ASP.NET login control

开发者 https://www.devze.com 2022-12-17 08:59 出处:网络
I am trying to localize stan开发者_StackOverflowdart ASP.NET login control. When I change page culture I want label \'password\' to be automatically translated. I know how to work with resources in AS

I am trying to localize stan开发者_StackOverflowdart ASP.NET login control. When I change page culture I want label 'password' to be automatically translated. I know how to work with resources in ASP.NET but I do not want to make localization myself, I am sure that microsoft has already translated all captions and error messages.


Follow this instruction :

  1. Download and install the German language pack for .NET 2.0

  2. In the webform's source, add UICulture="auto" in the <%@ Page directive, for example: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" UICulture="auto" %>

  3. View this page in browser, change your browser's preferred language to German, Then you should see the login control displayed in German language.

If you installed other language packs, users browsing your web site can set their preferred language and your web page will display in the language if its installed.

Hope this help you.

Source


You can try on your login control to press the tooltip and then click layout template.

Here you will get your control just like this :

<asp:Login ID="loginForm" runat="server" Height="200px" Width="442px">
                            <LayoutTemplate>
                                <table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
                                    <tr>
                                        <td class="style3">
                                            <table cellpadding="0" style="height:200px;">
                                                <tr>
                                                    <td align="center" colspan="2">
                                                        &nbsp;</td>
                                                </tr>
                                                ...etc

You will find your controls as the user name label :

<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" Text="<%$Resources:YourResourcefile,Key%>"></asp:Label>

and you can localize what you want.


If you can't or don't want to install the language pack, you can take control of the texts displayed by the Login control, using the UserNameLabelText, PasswordLabelText and LoginButtonText properties. Set them to your own resources, for example:

UserNameLabelText="<%$ Resources:resxfilename, m_lblUsername %>"
0

精彩评论

暂无评论...
验证码 换一张
取 消