Web控制項文字框Reset的功能

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   os   使用   sp   

在前一篇中《怎樣實現Web控制項文字框Reset的功能》http://www.cnblogs.com/insus/p/4120889.html Insus.NET只實現了文字框的功能。單個或是多個,有預設值與無值。只要使用者點擊重設(Reset)時,我們就要以對Web控制項進行重設。

參考博文,其實你完全可以寫出其它的控制項的重設功能來。如DropDownLsit,ListBox,CheckBox,CheckBoxList,RadioButtonList等等。

想實現什麼控制項Reset功能,均需要建立一個自訂類,並繼承它。

下面是CheckBox控制項:



ListBox控制項Reset功能:



CheckBoxList控制項:


DropDownList控制項:

 
RadioButtonList控制項:

下面是分別使用程式來示範:

 <asp:TextBox ID="TextBox1" runat="server" Text="Leo"></asp:TextBox><br />                      <asp:DropDownList ID="DropDownList1" runat="server">                <asp:ListItem Value="A" Text="A"></asp:ListItem>                <asp:ListItem Value="B" Text="B"></asp:ListItem>                <asp:ListItem Value="C" Text="C"></asp:ListItem>                <asp:ListItem Value="D" Text="D"></asp:ListItem>                <asp:ListItem Value="E" Text="E"></asp:ListItem>                <asp:ListItem Value="F" Text="F"></asp:ListItem>                <asp:ListItem Value="G" Text="G"></asp:ListItem>            </asp:DropDownList><br />            <asp:CheckBox ID="CheckBox1" runat="server" /><br />            <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="7">                <asp:ListItem Value="A" Text="A"></asp:ListItem>                <asp:ListItem Value="B" Text="B"></asp:ListItem>                <asp:ListItem Value="C" Text="C"></asp:ListItem>                <asp:ListItem Value="D" Text="D"></asp:ListItem>                <asp:ListItem Value="E" Text="E"></asp:ListItem>                <asp:ListItem Value="F" Text="F"></asp:ListItem>                <asp:ListItem Value="G" Text="G"></asp:ListItem>            </asp:CheckBoxList><br />            <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3">                <asp:ListItem Value="A" Text="A"></asp:ListItem>                <asp:ListItem Value="B" Text="B"></asp:ListItem>                <asp:ListItem Value="C" Text="C"></asp:ListItem>            </asp:RadioButtonList><br />            <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">                <asp:ListItem Value="A" Text="A"></asp:ListItem>                <asp:ListItem Value="B" Text="B"></asp:ListItem>                <asp:ListItem Value="C" Text="C"></asp:ListItem>                <asp:ListItem Value="D" Text="D"></asp:ListItem>                <asp:ListItem Value="E" Text="E"></asp:ListItem>            </asp:ListBox><br />            <asp:Button ID="Button1" runat="server" Text="Reset" OnClick="Button1_Click" />
View Code

 

現在寫Reset銨鈕事件,不能照搬前一篇的方法,但需要修改一下,因為所有自訂都有實作了介面IResetControlable。



動態操作示範一下:

 
上面所有控制項示範中,僅列出一個,如果在一個銨鈕事件,針對多控制項時,我們又需要怎樣去最佳化上面的程式,哪些需要修改,哪些不需要動了。其實asp.net開發中,使用控制項才更多機會學到物件導向的技術和知識。

Web控制項文字框Reset的功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.