主要有:Label、TextBox、Button、RadioButton、CheckBox、RadioButtonList、CheckBoxList、HyperLink控件。
控件
Label、TextBox
<form id="form1" runat="server">
<div>
<!--html控件,html服务器端控件,asp.net服务端控件-->
<input type="text" name="uname1" /><br />
<input type="text" name="uname1" runat="server"/><br />
<asp:Label ID="lbl" Text="我是服务器端控件" runat="server" />
</div>
</form>
TextBox:设置密码或多行
使用TextMode属性; SingleLine:单行 Password:密码;Multiline:多行;
AutoPostBack:自动提交;
RadioButton RadioButtonList
GroupName:设置这个
Text Value
String msg = "";
?
if (RadioButton1.Checked)
msg += RadioButton1.Text;
if (RadioButton2.Checked)
msg += RadioButton2.Text;
//asxh:request response
?
msg+=",直辖市:"+RadioButtonList1.SelectedItem.Text+",竞争力值:"+RadioButtonList1.SelectedValue;
Response.Write("性别:"+msg);
DropDowList
if (DropDownList1.SelectedItem.Text != "请选择所在城市")
Response.Write("您所在的城市为:"+DropDownList1.SelectedItem.Text);
else
Response.Write("请选择所在城市");
LIstBox控件,是将DropDowList的内容,可以一次性显示出来。DropDownList下拉效果。
for (int i = srcList.Items.Count - 1; i >= 0; i--) {
//先获取源头List的Items[i]项
//ListItem item = srcList.Items[i];
//if (item.Selected) {
// destList.Items.Add(item);
// srcList.Items.Remove(item);
//}
//多种方式的实现
ListItem item=srcList.SelectedItem;
if (item!=null)
{
destList.Items.Add(srcList.SelectedItem);
srcList.Items.Remove(srcList.SelectedItem);
}
}
CheckBox、CheckBoxList
string msg = " ",hobby="";
?
if (CheckBox1.Checked)
msg += CheckBox1.Text;
if (CheckBox2.Checked)
msg += CheckBox2.Text;
if (CheckBox3.Checked)
msg += CheckBox3.Text;
if (CheckBox4.Checked)
msg += CheckBox4.Text;
if (CheckBox5.Checked)
msg += CheckBox5.Text;
//针对CheckBoxList做一个循环
for (int i = 0; i < CheckBoxList1.Items.Count; i++) {
//其中每一项是一个Item,属性是Selected
if (CheckBoxList1.Items[i].Selected) {
hobby += CheckBoxList1.Items[i].Text;
}
}
?
?
String str = String.Format(@"您的期待岗位是‘{0}‘,爱好是‘{1}‘", msg,hobby);
Response.Write(str);