在asp.net图像定位 [英] Image localization in asp.net
问题描述
我有需要支持多国语言的Web应用程序。目前,我们在他们的文字在网站上相当多的图片。我试着去找到一个方法来定位这些图像与麻烦最少。我有什么想出这么远是子文件夹添加到其中涉及到所需的语言电流/图片文件夹中。因此,例如/图片包含图像和/图片的默认设置/ ES-MX包含了西班牙籍局部图像。
所有pretty标准到目前为止,我认为。现在,这个问题我已经是,为了这个新的结构工作,我需要将以下添加到所有的img标签:
< IMG ... SRC =/图像/<%= GetGlobalResourceObject(MyResource,的ImagePath)。的ToString()%GT; image1.gif。 ./>
还是在ASP的情况下:ImageButton的我需要通过编程设置其在codebehind IMAGEURL与替换/图像/带/图片/ ES-MX或任何文化的恰好是一个工具方法。 p>
这一切给我留下了凌乱的标记和大量codebehind的呼吁只是为了纠正图像的路径。我问你亲爱的读者,有没有更好的办法?
下面是从MSDN上在ASP.NET全球化的好文章。它使用一个资源文件的方法,所以我不知道这会为你工作,但这里是文章:
http://msdn.microsoft.com/en-us/magazine/ cc163566.aspx
I have a web application which needs to support multiple languages. We currently have quite a lot of images on the site with text in them. Im trying to find a way to localize these images with the least amount of hassle. What i have come up with so far is to add sub folders to the current /Images folder which relate to the required language. So for example /Images contains the default set of images and /Images/es-MX contains the Spanish-Mexican localised images.
All pretty standard so far i think. Now the issue i have is that in order for this new structure to work i need to add the following to all img tags:
<img ... src="/images/<%= GetGlobalResourceObject("MyResource","IMAGEPATH").ToString() %>image1.gif" ../>
Or in the case of asp:ImageButton i need to programmatically set their ImageURL in codebehind with a utility method that replaces the /Images/ with /Images/es-MX or whatever the culture happens to be.
All of this leaves me with messy markup and lots of codebehind calls just to correct the image path. I ask you dear reader, is there a better way?
Here is a good article from MSDN on globalization in ASP.NET. It uses a resource file approach so I am not sure if that will work for you but here is the article:
http://msdn.microsoft.com/en-us/magazine/cc163566.aspx
这篇关于在asp.net图像定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!