首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

改变按钮图片解决思路

2012-03-11 
改变按钮图片两个控件CheckBox idchkbAgreeASP:ButtonidbtnEnter用js方法,当checkbox选中的时候,改

改变按钮图片
两个控件
CheckBox id="chkbAgree"
ASP:Button id="btnEnter"
用js方法,当checkbox选中的时候,改变button的图片。
js:
if (ckbAgree.checked) {
  //改变图片样式
  btnEnter.CssClass = "btnRegister";//方法无效
  btnEnter.setAttribute("background-image", "url(../images/btnclose.jpg)");//方法无效
  btnEnter.setAttribute("background", "url(../images/btnclose.jpg)");//方法无效
}


[解决办法]
是可以的,可能是你的图片路径有问题。另外得到id对象
是采用
document.getElementById('<%=ckbAgree.ClientID%>')
[解决办法]

HTML code
    <asp:CheckBox ID="chkbAgree" runat="server"         oncheckedchanged="chkbAgree_CheckedChanged"  AutoPostBack="true"/>    <asp:Button ID="btnEnter" runat="server" Text="Button" />
[解决办法]
错了
应该是
document.getElementById('<%=btnEnter.ClientID %>').style.backgroundImage= "url(http://dotnet.aspx.cc/Images/logoSite.gif)"

or
btnEnter.setAttribute("style", "background-image:url(../images/btnclose.jpg)");无效

热点排行