• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上

asp 搞代码 4年前 (2022-01-03) 31次浏览 已收录 0个评论

一直想实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上。此功能就是当鼠标经过时RadioButtonList或CheckBoxList每一个Item时,让Item有特效显示,离开时,恢复原样有演示动画,感兴趣的朋友可以了解下啊

一直想实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上,今晚终于有时间实现它。此功能就是当鼠标经过时RadioButtonList或CheckBoxList每一个Item时,让Item有特效显示,离开时,恢复原样。可以看到

RadioButtonList

CheckBoxList

 

这资实现数据,Insus.NET准备了五行(Five Phases)

 

创建一个对象[Five Phases]:
FivePhases.cs

代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

///

/// Summary description for FivePhases
///

public class FivePhases
{
private int _ID;
private string _Name;

public int ID
{
get { return _ID; }
set { _ID = value; }
}

public string Name
{
get { return _Name; }
set { _Name = value; }
}

public FivePhases()
{
//
// TODO: Add constructor logic here
//
}

public FivePhases(int id, string name)
{
this.ID = id;
this._Name = name;
}
}

代码如下:
private List GetFivePhases()
{
List ListFH = new List();
FivePhases fh = new FivePhases();
fh.ID = 1;
fh.Name = “木”;
ListFH.Add(fh);

fh = new FivePhases();
fh.ID = 2;
fh.Name = “火”;
ListFH.Add(fh);

fh = new FivePhases();
fh.ID = 3;
fh.Name = “土”;
ListFH.Add(fh);

fh = new FivePhases();
fh.ID = 4;
fh.Name = “金”;
ListFH.Add(fh);

fh = new FivePhases();
fh.ID = 5;
fh.Name = “水”;
ListFH.Add(fh);

return ListFH;
}

此时,你可以拉一个RadioButtonList或是CheckBoxList控件至网页中,此例以RadioButtonList控件为例。

代码如下:

然后在cs绑定数据:

代码如下:
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Data_Binding();
}

private void Data_Binding()
{
this.RadioButtonListFivePhases.DataSource = Get来源gao*daima.com搞@代#码网FivePhases();
this.RadioButtonListFivePhases.DataTextField = “Name”;
this.RadioButtonListFivePhases.DataValueField = “ID”;
this.RadioButtonListFivePhases.DataBind();
}

}

还得准备鼠标的over与out样式:

代码如下:

.overStyle {
font-weight: bold;
color: #f00;
}

.outStyle {
font-weight: normal;
color: none;
}

在Javascript中实现每个Item有onmouseover和onmouseout事件,因此还得写Javascript脚本,放于内。

代码如下:

以上就是实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址