I'm in testing Localization for my website ; 2 langauge been used English and Arabic.
I used 2 Global Resource file , It works fine for text, hyperlinks ; my question is How to read image from global resource File; since the arabic will have different banner and english will have differernt banner.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.ToShortDateString();
}
protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
UICulture = Request.Form["DropDownList1"];
Culture = Request.Form["DropDownList1"];
}
base.InitializeCulture();
}
}
Images are served from their own http request, so you should implement a IHttpHandler to serve them up. The hander can then load the right image resource.
rmda
0 Points
1 Post
Image file from Global Resource File
Jun 09, 2012 11:20 AM|LINK
Hi,
I'm in testing Localization for my website ; 2 langauge been used English and Arabic.
I used 2 Global Resource file , It works fine for text, hyperlinks ; my question is How to read image from global resource File; since the arabic will have different banner and english will have differernt banner.
default.aspx
--------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" UICulture="auto" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem Value="en-us">English</asp:ListItem> <asp:ListItem Value="ar-AE">Arabic</asp:ListItem> </asp:DropDownList> </div> <asp:HyperLink ID="HyperLink1" runat="server" Text="<%$ Resources:LocalizedText, HyperLink1 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink2" runat="server" Text="<%$ Resources:LocalizedText, HyperLink2 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink3" runat="server" Text="<%$ Resources:LocalizedText, HyperLink3 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink4" runat="server" Text="<%$ Resources:LocalizedText, HyperLink4 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink5" runat="server" Text="<%$ Resources:LocalizedText, HyperLink5 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink6" runat="server" Text="<%$ Resources:LocalizedText, HyperLink6 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink7" runat="server" Text="<%$ Resources:LocalizedText, HyperLink7 %>"></asp:HyperLink> <asp:HyperLink ID="HyperLink8" runat="server" Text="<%$ Resources:LocalizedText, HyperLink8 %>"></asp:HyperLink> </div> <div> <asp:Label ID="Msg1" runat="server" meta:resourcekey="lblWelcomeResource1" Text="<%$ Resources:LocalizedText, Msg1 %>"></asp:Label> <br /> <br /> <asp:Label ID="Hello" runat="server" meta:resourcekey="lblNoticeResource1" Text="<%$ Resources:LocalizedText, Hello %>"></asp:Label> <asp:Label ID="lblTime" runat="server" meta:resourcekey="lblTimeResource1"></asp:Label></div> </form> </body> </html>default.aspx.cs
----------------
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lblTime.Text = DateTime.Now.ToShortDateString(); } protected override void InitializeCulture() { if (Request.Form["DropDownList1"] != null) { UICulture = Request.Form["DropDownList1"]; Culture = Request.Form["DropDownList1"]; } base.InitializeCulture(); } }Regards,
Mohamed
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: Image file from Global Resource File
Jun 09, 2012 10:27 PM|LINK
Images are served from their own http request, so you should implement a IHttpHandler to serve them up. The hander can then load the right image resource.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/