Button 控件提供命令按钮样式的控件,用于将 Web 窗体页面回发给服务器。下面的示例说明简单 Button 控件的使用。
<asp:Button id=Button1 Text="单击我" onclick="Button1_Click" runat="server" />
2.CheckBox 复选框控件
CheckBox 服务器控件接受输入布尔值(true 或 false)。当选定该控件时,其 Checked 属性为 true。通常将复选框作为窗体中的几个字段之一进行处理。但是,如果其 AutoPostBack 属性为 true,则可以用于触发到服务器的回发。下面的示例说明 CheckBox 控件的使用。
<asp:CheckBox id=Check1 Text="复选框 1" runat="server" />
3.CheckBoxList
CheckBoxList 控件提供可以进行多重选择的列表。同其他列表控件相似,CheckBoxList 有一个 Items 集合。该集合的成员与列表中的每个项相对应。要确定选中了那些项,请测试每项的 Selected 属性。
可以用 RepeatLayout 和 RepeatDirection 属性来控制列表的呈现形式。如果 RepeatLayout 是 Table,那么该列表将在表中呈现。如果设置成 Flow,那么该列表将在没有任何表结构的情况下呈现。默认情况下,RepeatDirection 为 Vertical。将此属性设置成 Horizontal 将会使列表水平呈现。
下面的示例说明 CheckBoxList 控件的使用。
<asp:CheckBoxList id=Check1 runat="server">
<asp:ListItem>项 1</asp:ListItem>
<asp:ListItem>项 2</asp:ListItem>
<asp:ListItem>项 3</asp:ListItem>
<asp:ListItem>项 4</asp:ListItem>
<asp:ListItem>项 5</asp:ListItem>
<asp:ListItem>项 6</asp:ListItem>
</asp:CheckBoxList>
4.DropDownList
DropDownList 控件提供单选的下拉列表。下面的示例说明简单 DropDownList 控件的使用。
<asp:DropDownList id=DropDown1 runat="server">
<asp:ListItem>项 1</asp:ListItem>
<asp:ListItem>项 2</asp:ListItem>
<asp:ListItem>项 3</asp:ListItem>
<asp:ListItem>项 4</asp:ListItem>
<asp:ListItem>项 5</asp:ListItem>
<asp:ListItem>项 6</asp:ListItem>
</asp:DropDownList>
5.HyperLink
HyperLink 控件用于从客户端定位到另一页面。下面的示例说明简单 HyperLink 控件的使用。
<asp:hyperlink id=HyperLink1 runat="server">转到快速入门</asp:hyperlink>
评论内容:发表评论不能请不要超过250字;发表评论请自觉遵守互联网相关政策法规。