濮阳杆衣贸易有限公司

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

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

熱門標(biāo)簽:電話機(jī)器人軟件銷售工作 玉林市機(jī)器人外呼系統(tǒng)哪家好 預(yù)測(cè)式外呼系統(tǒng)使用說明 南陽外呼系統(tǒng)定制化 合肥電銷外呼系統(tǒng)哪家公司做的好 蘋果手機(jī)凱立德地圖標(biāo)注 百度ai地圖標(biāo)注 申請(qǐng)400電話手續(xù) 同安公安400電話怎么申請(qǐ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ù)原樣。可以看到效果:

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 ListFivePhases> GetFivePhases()
{
ListFivePhases> ListFH = new ListFivePhases>();
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>

您可能感興趣的文章:
  • 兼容ie和firefox的鼠標(biāo)經(jīng)過(onmouseover和onmouseout)實(shí)現(xiàn)--簡(jiǎn)短版
  • javascript mouseover、mouseout停止事件冒泡的解決方案
  • js ondocumentready onmouseover onclick onmouseout 樣式
  • onmouseover和onmouseout的一些問題思考
  • 基于mouseout和mouseover等類似事件的冒泡問題解決方法
  • 經(jīng)過綁定元素時(shí)會(huì)多次觸發(fā)mouseover和mouseout事件
  • javascript中mouseover、mouseout使用詳解

標(biāo)簽:南昌 臺(tái)州 揚(yáng)州 南京 海南 嘉興 淄博 南京

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上》,本文關(guān)鍵詞  實(shí)現(xiàn),onmouseover,和,onmouseout,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上》相關(guān)的同類信息!
  • 本頁收集關(guān)于實(shí)現(xiàn)onmouseover和onmouseout應(yīng)用于RadioButtonList或CheckBoxList控件上的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    图木舒克市| 民县| 邹城市| 炉霍县| 扶绥县| 祥云县| 曲松县| 临泽县| 澄江县| 益阳市| 贵溪市| 门源| 道孚县| 临江市| 巩留县| 庆安县| 诏安县| 周至县| 磐安县| 宝兴县| 巴彦淖尔市| 玉溪市| 城市| 故城县| 安徽省| 沁水县| 深水埗区| 疏勒县| 建水县| 谢通门县| 贵德县| 临澧县| 安溪县| 天津市| 余庆县| 宜州市| 呼图壁县| 莲花县| 汝州市| 大渡口区| 枣庄市|