根据母版页控件的值,需要在同一页面上显示2个差异横幅小精灵 [英] Need to display 2 diff banner sprites on same page based on the value of a control of Master Page

查看:61
本文介绍了根据母版页控件的值,需要在同一页面上显示2个差异横幅小精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

母版页上有一个标签控件.如果其值为"Value1",我要此CSS Sprite显示在我的Web窗体上.如果值是"Value2",则CSS Sprite应该使用其他图片.只是需要更改图片.Sprite中没有其他内容.

there's a label control on the master page..if its value is "Value1" ,I want this CSS Sprite to display on my webform..if the Value is "Value2"..the CSS sprite should use some different image..just the image needs to be changed ..nothing else in that Sprite..

我发现我可以使用"FindControl"方法来找出母版页的标签控件"当前具有什么值.

I found out that I can use "FindControl" method to find out what value that Label Control of Master Page's currently got..

现在如何更改横幅上的图像?我该怎么办?另外,CSS Sprite现在是一个名为"myBanner.ascx"的用户控件(以前是aspx文件).现在我需要制作2个diff用户控件,还是可以在一个usercontrol本身中实现一些逻辑?

Now how do I change that image on the banner ?? How do I go about it ? Also that CSS Sprite now is a user control named "myBanner.ascx"(earlier was an aspx file)..Now do I need to make 2 diff usercontrols or I can implement some logic in one usercontrol itself ?

我应该用它的CSS中的图像名称"更改来制作此"myBanner.ascx"的2个副本吗?

Should I make 2 copies of this "myBanner.ascx" with JUST the "image name" changed in its CSS ???

希望它不会引起混淆.实际上我迷路了:/

Hope its not confusing..Actually I am lost :/

我想要的是使用CSS Sprite制作的一个横幅.现在,如果母版页中标签控件"的值是"Value1",则该横幅上要使用的图像是"IMAGE1",否则,如果标签控件的值为" Value2,然后在该子画面中使用" IMAGE2.

What I want is ONE banner which has been made using CSS Sprite ..Now if the "Label Control's "value in the master page is "Value1" then the image to be used on that banner is "IMAGE1" else if "Label Control's" value is "Value2" then "IMAGE2" should be used in that sprite..

我该怎么做?只需要想法..thnx

How do I go about it ? Need just ideas..thnx

推荐答案

首先,仅使用一个用户控件.

First of all, use only one usercontrol.

在用户控件内,您可以添加带有图像路径的 string变量.

Inside your user control you can add a string variable with the image path.

然后在具有该图像的控件上使用

Then on your control that have this image just overwrite the css style by using the

style="background-image:url(imagePathFromVarible)"

在页面上声明用户控件时,通过编程更改图像路径ether,在声明上更改ether ...

When you declare your usercontrol on the page, change the image path ether by programming, ether on declare...

我希望我可以理解...如果没有,请告诉我给您更多信息.

I hope that I am understandable... if not please tell me to give you some more infos.

这篇关于根据母版页控件的值,需要在同一页面上显示2个差异横幅小精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆