这样?
if(Button1.ImageUrl == "Images/1.gif")
{
Button1.ImageUrl = "Images/2.gif";
}
else if (Button1.ImageUrl = "Images/2.gif";)
{
Button1.ImageUrl = "Images/1.gif";
}
if(Button1.ImageUrl == "Images/1.gif")
{
Button1.ImageUrl = "Images/2.gif";
}
else if (Button1.ImageUrl = "Images/2.gif";)
{
Button1.ImageUrl = "Images/1.gif";
}
btn.Attributes.Add("class","button");
btn.Attributes.Add("onmouseover","this.className='buttonover'");
btn.Attributes.Add("onmouseout","this.className='buttonout'");
CSS里面对应的部分:
.button{width:100; height:20;BACKGROUND: url("/AppBaGang/images/button/button_v3.gif") repeat-y; border:0 solid silver; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-VARIANT: normal; FONT-WEIGHT: normal; LINE-HEIGHT: normal}.buttonover{width:100; height:20;BACKGROUND: url("/AppBaGang/images/button/button_v4.gif") repeat-y; border:0 solid silver; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-VARIANT: normal; FONT-WEIGHT: normal; LINE-HEIGHT: normal}.buttonout{width:100; height:20;BACKGROUND: url("/AppBaGang/images/button/button_v3.gif") repeat-y; border:0 solid silver; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-VARIANT: normal; FONT-WEIGHT: normal; LINE-HEIGHT: normal}上面可以达到同样的效果!
onMouseOver 图2要这样的效果
btnNew.Attributes.Add("onmouseover", "this.src='../Imgs/new_over.gif'");
btnNew.Attributes.Add("onmouseout", "this.src='../Imgs/new_out.gif'");