asp.net的button控件没有onmouse事件?

来源:百度知道 编辑:UC知道 时间:2024/09/22 20:30:40
想实现
onmouseover="this.className='btn'" onmouseout="this.className='btn1'"
但asp的button没有onmouse事件,怎么处理,谢谢

因为Button是服务器端控件,没有onmouse系列的事件,因为不可能在服务器端触发只有客户端才能触发的事件。(鼠标一移动上去就跳转,不可能吧)

对于客户端的事件,可以在后置代码中进行指定,也可以直接在Button的标签声明后指定。只是没有智能提示,并不是没有咯。

后置代码:
button.Attributes.Add("onmouseover", "alert('鼠标移上来了!')");

按钮没有onmouseover和 onmouseout事件吧。。你可以用图片代替按钮啊。然后设置图片的onmouseover和 onmouseout

buttonid.Attributes.Add("onmouseover","this.className='btn'");
buttonid.Attributes.Add("onmouseout","this.className='btn1'");