欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上

 更新時(shí)間:2013年01月24日 09:21:49   作者:  
一直想實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上。此功能就是當(dāng)鼠標(biāo)經(jīng)過時(shí)RadioButtonList或CheckBoxList每一個(gè)Item時(shí),讓Item有特效顯示,離開時(shí),恢復(fù)原樣有演示動(dòng)畫,感興趣的朋友可以了解下啊

一直想實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上,今晚終于有時(shí)間實(shí)現(xiàn)它。此功能就是當(dāng)鼠標(biāo)經(jīng)過時(shí)RadioButtonList或CheckBoxList每一個(gè)Item時(shí),讓Item有特效顯示,離開時(shí),恢復(fù)原樣??梢钥吹叫Ч?/P>

RadioButtonList效果:


CheckBoxList效果:

 

這資實(shí)現(xiàn)數(shù)據(jù),Insus.NET準(zhǔn)備了五行(Five Phases)

 

創(chuàng)建一個(gè)對(duì)象[Five Phases]:
FivePhases.cs

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for FivePhases
/// </summary>
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;
}
}

復(fù)制代碼 代碼如下:

private List<FivePhases> GetFivePhases()
{
List<FivePhases> ListFH = new List<FivePhases>();
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;
}

此時(shí),你可以拉一個(gè)RadioButtonList或是CheckBoxList控件至網(wǎng)頁中,此例以RadioButtonList控件為例。
復(fù)制代碼 代碼如下:

<asp:CheckBoxList ID="RadioButtonListFivePhases" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList>

然后在cs綁定數(shù)據(jù):
復(fù)制代碼 代碼如下:

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 = GetFivePhases();
this.RadioButtonListFivePhases.DataTextField = "Name";
this.RadioButtonListFivePhases.DataValueField = "ID";
this.RadioButtonListFivePhases.DataBind();
}

}

還得準(zhǔn)備鼠標(biāo)的over與out樣式:
復(fù)制代碼 代碼如下:

<style type="text/css">
.overStyle {
font-weight: bold;
color: #f00;
}

.outStyle {
font-weight: normal;
color: none;
}
</style>

在Javascript中實(shí)現(xiàn)每個(gè)Item有onmouseover和onmouseout事件,因此還得寫Javascript腳本,放于<head>內(nèi)。
復(fù)制代碼 代碼如下:

<script type="text/javascript">
function windowOnLoad() {
var rbl = document.getElementById('<%= RadioButtonListFivePhases.ClientID %>');
var labels = rbl.getElementsByTagName('label');

for (var i = 0; i < labels.length; i++) {
var lbl = labels[i];

lbl.onmouseover = function () {
this.className = 'overStyle';
};

lbl.onmouseout = function () {
this.className = 'outStyle';
};
}
}
window.onload = windowOnLoad;
</script>

相關(guān)文章

最新評(píng)論