图文详解asp.net自带控件
1 Button類(lèi)控件
三種button控件;
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="單擊按鈕" Height="38px" />
? ? ? ? <asp:ImageButton ID="ImageButton1" runat="server" Height="36px" ImageUrl="~/PT12.jpg"
? ? ? ? ? ? OnClick="ImageButton1_Click" Width="73px" />
? ? ? ? <asp:LinkButton ID="LinkButton1" runat="server" Height="35px" OnClick="LinkButton1_Click"
? ? ? ? ? ? Style="text-align: center" Width="74px" Text="鏈接按鈕"></asp:LinkButton><br />
2 文本類(lèi)控件
在文本框中輸入內(nèi)容,輸入完回車(chē),在TextBox1_TextChanged事件中改變Label控件的值;
3 列表框控件
<asp:ListBox ID="lbCity" runat="server" Height="118px" OnSelectedIndexChanged="lbCity_SelectedIndexChanged">
? ? ? ? ? ? <asp:ListItem>10KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>35KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>110KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>220KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>330KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>500KV</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>1000KV</asp:ListItem>
? ? ? ? </asp:ListBox>
4 單選按鈕
<br />
? ? ? ? <asp:RadioButton ID="rbQH" runat="server" GroupName="xxGroup" Text="小兔子" AutoPostBack="True" OnCheckedChanged="rbMale_CheckedChanged" />
? ? ? ? <asp:RadioButton ID="rbBD" runat="server" GroupName="xxGroup" Text="小狗狗" />
? ? ? ? <asp:RadioButton ID="rbZD" runat="server" GroupName="xxGroup" Text="小白兔" /><br />
5 多選控件
<asp:CheckBox ID="cbYundong" runat="server"
? ? ? ? ? ? OnCheckedChanged="cbYundong_CheckedChanged" Text="小兔子" />
? ? ? ? <asp:CheckBox ID="cbYinyue" runat="server" Text="小狗狗" />
? ? ? ? <asp:CheckBox ID="cbWenxue" runat="server" Text="小貓咪" />
? ? ? ? <asp:CheckBox ID="cbWudao" runat="server" Text="小倉(cāng)鼠" />
6 多選控件
前后兩個(gè)的實(shí)現(xiàn)方式不同,代碼如下,一個(gè)用CheckBox實(shí)現(xiàn),一個(gè)用CheckBoxList實(shí)現(xiàn)
<asp:CheckBox ID="cbYundong" runat="server"
? ? ? ? ? ? OnCheckedChanged="cbYundong_CheckedChanged" Text="運(yùn)動(dòng)" />
? ? ? ? <asp:CheckBox ID="cbYinyue" runat="server" Text="音樂(lè)" />
? ? ? ? <asp:CheckBox ID="cbWenxue" runat="server" Text="文學(xué)" />
? ? ? ? <asp:CheckBox ID="cbWudao" runat="server" Text="舞蹈" /><br />
? ? ? ? <br />
? ? ? ? <asp:Label ID="lblMessage" runat="server" Width="266px"></asp:Label><br />
? ? ? ? <br />
? ? ? ? <asp:Button ID="btnSubmit" runat="server" Text="提交" OnClick="btnSubmit_Click" /><br />
? ? ? ? <br />
? ? ? ? <br />
? ? ? ? <br />
? ? ? ? <br />
? ? ? ? 愛(ài)好:<asp:CheckBoxList ID="cblHobby" runat="server"
? ? ? ? ? ? RepeatDirection="Horizontal" RepeatLayout="Flow">
? ? ? ? ? ? <asp:ListItem>運(yùn)動(dòng)</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>音樂(lè)</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>文學(xué)</asp:ListItem>
? ? ? ? ? ? <asp:ListItem>舞蹈</asp:ListItem>
? ? ? ? </asp:CheckBoxList><br />
7 日歷控件
前一個(gè)SelectMode為Day,后一個(gè)為DayWeek;前者只能選定一天,后者可選擇一個(gè)星期;
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
? ? {
? ? ? ? Text1.Text = String.Format("You selected {0} date(s).",Calendar1.SelectedDates.Count);
? ? ? ? Text2.Text = String.Format("You selected date:{0}", Calendar1.SelectedDate);
? ? }
工程源碼下載:
http://pan.baidu.com/s/1o6Jtmae
總結(jié)
以上是生活随笔為你收集整理的图文详解asp.net自带控件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: .Net装箱拆箱编程实例
- 下一篇: .net中XML编程总结