我们有一个多语言网站,或文化敏感的,一些静态内容现在需要针对性;为此,我使用主题,因为它似乎达到我想要的最简单的方法,但我不能为我的生活让图像拾起。ASP.NET主题以编程方式:图片路径
我在代码隐藏中设置主题,起初认为可能是这个问题,但在检查时,它看起来像我正在做正确的事情(设置在Pre-Init
)。
我希望能够引用使用相对路径,其中App_Themes/ThemeName/
会自动解决,如图像,:
<asp:Image runat="server" ImageUrl="images\image.jpg"/>
无论出于何种原因,但是,图像不被通过拉可言。
这是我们已有的代码来设置主题(唯一真正相关的部分,我敢肯定,作为Theme = CurrentSite.CultureName
,这是成功应用):
Private Sub SetTheme()
Dim themesPath = Server.MapPath("~/App_Themes")
If Directory.Exists(themesPath) Then
Dim themePaths = Directory.GetDirectories(themesPath)
Dim themePathInfo As DirectoryInfo
For Each _path In themePaths
themePathInfo = New DirectoryInfo(_path)
If Not themePathInfo Is Nothing Then
If themePathInfo.Name = CurrentSite.CultureName Then
Theme = CurrentSite.CultureName
Exit For
End If
End If
Next
End If
End Sub
在上面的代码, CurrentSite.CultureName
将是一个语言文化名称(例如,en-gb或nn-no),它具有包含所有必需资源的现有相应主题文件夹。
页面确实有EnableTheming
设置为True
。另外,我尝试删除主题设置代码并在页面中使用Theme="en-gb"
无效。
有没有什么立即明显的为什么网址没有解决?
对于每个图像?这是我主要关心的问题,因为有些图像是根据数据实时生成的。 – 2011-03-21 13:43:14
好的 - 更新了我的答案。 – 2011-03-21 13:55:20
感谢您的回答;这是我所推迟的,但看起来可能是唯一的解决方案 - 至少暂时是这样。 – 2011-03-23 21:38:33