ASP.NET在ImageUrl Porperty中动态设置主题名称

时间:2013-02-15 07:59:27

标签: html css internet-explorer

我使用过我硬编码的图像。但有多项目的选项,我想用它,如果一个人选择蓝色主题,那么蓝色图像应该显示,如果选择橙色主题,那么橙色图像应该出现..

这是我硬编码的ASP.NET图像代码

<asp:Image ID="Image4" runat="server" ImageUrl="~/App_Themes/Default/Images/listingnext.png" />

但我不希望它像我想要在主题基础上显示图像,就像我说如果它的蓝色然后蓝色图像显示,如果橙色或红色然后他们各自的图像应该显示..

我试过这样的。

<asp:Image ID="Image4" runat="server" ImageUrl="~/App_Themes/Default"+<%this.Theme%>+"/Images/listingnext.png" />

但它不起作用,如何使它成为可能?

1 个答案:

答案 0 :(得分:1)

Morpheus是对的,而不是使用以下;

"<%=ResolveUrl(string.Format("~/App_Themes/{0}/Images/listingnext.png", Page.Theme)) %>"

试试这个;

'<%# ResolveUrl(string.Format("~/App_Themes/{0}/Images/listingnext.png", Page.Theme)) %>'