WebForm Repeater:重复器

上午没有学习新的内容,做注册界面,用js写验证

<script type="text/javascript">
window.onload = function () {
document.getElementById("Button1").onclick = function () {
//用户名验证开始
var unameOK = true;
var oUname = document.getElementById("UserName_TextBox").value;
if (oUname == "") {
document.getElementById("UserError_Label").innerHTML = "用户名不能为空";
unameOK = false;
}
else {
document.getElementById("UserError_Label").innerHTML = "";
unameOK = true;
}
//用户名验证结束

//密码验证开始,密码两次是否一致
var pwdOK = true;
var oPwd1 = document.getElementById("Pwd1_TextBox").value;
var oPwd2 = document.getElementById("Pwd2_TextBox").value;
if (oPwd1 != oPwd2) {
document.getElementById("PwdError_Label").innerHTML = "两次密码不一致!";
pwdOK = false;
}
else {
document.getElementById("PwdError_Label").innerHTML = "";
pwdOK = true;
}

//密码验证结束


if (unameOK == false || pwdOK == false) {
return false;
}
};
};
</script>

下午 学习的Repeater:重复器,主要有 五大模板

1.HeaderTemplate - 头模板  里面内容在开始显示一遍

2.ItemTemplate - 项模板  有多少条数据显示多少条

3.FooterTemplate -脚模板  里面内容在结束显示一遍

4.AlternatingItemTemplate - 交替项模板 与ItemTemplate一起用

-----------------------------------------------

数据绑定

list<Users> li =new usersData().Select();

Repeater1.DataSource=li;
Repeater1.DataBind();

数据内容显示

页面数据显示位置:<%#Eval("属性名") %>

1、显示最终数据

字段扩展

2、标记颜色显示

封装字段

public string red

{

get{

   if(age>16)

   {return "

   }

   else{return "";}

}

}

style=“<%#Eval("red") %>”

3:
光棒效果,并且保留原有颜色。

鼠标移出时 赋 鼠标移入前的颜色!

<script type="text/javascript">
var oItems = document.getElementsByClassName("tr_item");
for (var i = 0; i < oItems.length; i++)
{
var oldColor = "";
oItems[i].onmouseover = function ()

{
oldColor = this.style.backgroundColor;
this.style.backgroundColor = "yellow";
};

oItems[i].onmouseout = function ()

{
this.style.backgroundColor = oldColor;

};
}

原文地址:https://www.cnblogs.com/power8023/p/5968322.html