Retrieving Local Resources Programmatically : Resource file « I18N « ASP.NET Tutorial






File: ProgramLocal.aspx

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
    void Page_Load()
    {
        string welcomeMessage = (string)GetLocalResourceObject("welcomeMessage");
        lblMessage.Text = String.Format(welcomeMessage, "Steve");
    }

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Program Local Resource</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:Label
        id="lblMessage"
        Runat="server" />

    </div>
    </form>
</body>
</html>

File: App_LocalResources\ProgramLocal.aspx.es.resx
Name          Value
welcomeMessage  Welcome {0} to our website!








22.6.Resource file
22.6.1.Explicit Localization Expressions
22.6.2.Implicit Localization Expressions
22.6.3.Using Local Resources with Page Properties
22.6.4.You also can use implicit resource expressions when setting the page title.
22.6.5.Retrieving Local Resources Programmatically