简单控件
Label -作用是显示文字,编译后元素是Span
1.文本类
边框:
BorderColor 边框颜色
BordersTyle 边框样式
BorderWidth 边框粗细
Literal- 显示文字,编译后不会显示任何元素,一般被用来输出JS代码
TextBox - 文字输入框
TtextMode下面的属性:MultiLine 多行 password 密码框
Wrap 换行
Enabled 不可用
ReadOniy 只读
Maxlength 最大长度
2.按钮类
Button 按钮:
OnclientClick- confirm
InagrButton 图片按钮 inageurl
LinkButton 超链接按钮
HyperLink 超链接 - navigateurl 输入网址 tanget 打开新网址blank
http 协议无状态性: 每一次事件提交,都会将页面刷新,刷新就必走Load事件,重复绑定的情况
判断页面是第一次加载,还是 由已经加载出来的页面肿的某个按钮执行了提交返回回来的
!ispostback
二.复合控件
dropdownlist 下拉列表
一.将数据放进去
1.datasource
DropDownList1.DataSource = new NationData().Select();//数据源指向
DropDownList1.DataTextField = "NationName";//显示字段绑定
DropDownList1.DataValueField = "NationCode";//隐藏字段绑定
DropDownList1.DataBind();
2.foreach
if (!IsPostBack)
{
List<Nation> Nlist = new NationData().Select();
foreach (Nation n in Nlist)
{
ListItem li = new ListItem(n.NationName, n.NationCode);
if (li.Value == "N003")
{
li.Selected = true;
}
RadioButtonList1.Items.Add(li);
}
二.将数据取出来
Button1.Click += Button1_Click;//按钮1点击事件
1.读取一条数据
取出vakue值
取出text值
label1.text = dropdownlist1.selecteditem.text (.value)
2.listbox 读取多条选中的数据
可以多选 - selectionmode
string end = "";
foreach (ListItem li in RadioButtonList1.Items)
{
if (li.Selected)
{
end += li.Text + " - " + li.Value + ",";
}
}
Label1.Text = end;
checkboxlist -多选按钮 :repeatcolumns 水平显示几个 repeatdirection -横排 竖排 repeatlayout 用什么样的元素布局
radiobuttonlist -单选按钮