开发者

Changing images to a site depending on culture

i'm trying to change the ImageButton on my site using resx files. i tried assigning my ImageButton with meta:Reso开发者_运维技巧urceKey="imgBtnSubmit". then in my resx file, i added imgBtnSubmit.ImageUrl and assigned it the url to my new ImageButton. this didn't work for me. could someone tell me if i'm doing something wrong or if there is some other way i could do this? thanks.


You can do it writing a custom ExpressionBuilder.

That way you can influence the ImageUrl location based on your cultureinfo.

It would look like:

<asp:imagebutton runat="server" id="img1" ImageUrl="<%$ ImageResources: newItem.png %>" />

ImageResources is the name of the custom expressionbuilder. I my case i just needed to know the name of the image. I put my images in /app_themes/[theme name]/images/[culturecode] so my expressionbuilder creates that url based on the provided file name, current theme and culturecode.


Something else you may like to consider is having your buttons with a background image (or faking a button with some other element which has a background image), and overlaying the text. You will then be able to change the text based on culture without having to change the background image.


thanks for your answers but i got it working without having to create a custom ExpressionBuilder. there's a built-in 'Resources' ExpressionBuilder. This is what i did:

<asp:imagebutton runat="server" id="img1" ImageUrl="<%$Resources:ImageName%>"/>

default.aspx.resx:

ImageName ----- English_Image_Button.jpg

default.aspx.es.resx:

ImageName ----- Spanish_Image_Button.jpg
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜