In the previous article, "How to implement the Web control text box reset" http://www.cnblogs.com/insus/p/4120889.html insus.net only implemented the function of the text box. Single or multiple, with default values and no values. As soon as the user clicks Reset, we are going to reset the Web control.
Refer to the blog post, you can actually write the other controls to reset the function. such as Dropdownlsit,listbox,checkbox,checkboxlist,radiobuttonlist and so on.
To implement what the control reset function requires, you need to create a custom class and inherit it.
The following is a CheckBox control:
ListBox control Reset Function:
CheckBoxList CONTROLS:
DropDownList controls:
RadioButtonList CONTROLS:
Here's how to use the program to illustrate:
<Asp:textboxID= "TextBox1"runat= "Server"Text= "Leo"></Asp:textbox><BR/> <asp:dropdownlistID= "DropDownList1"runat= "Server"> <Asp:listitemValue= "A"Text= "A"></Asp:listitem> <Asp:listitemValue= "B"Text= "B"></Asp:listitem> <Asp:listitemValue= "C"Text= "C"></Asp:listitem> <Asp:listitemValue= "D"Text= "D"></Asp:listitem> <Asp:listitemValue= "E"Text= "E"></Asp:listitem> <Asp:listitemValue= "F"Text= "F"></Asp:listitem> <Asp:listitemValue= "G"Text= "G"></Asp:listitem> </asp:dropdownlist><BR/> <Asp:checkboxID= "CheckBox1"runat= "Server" /><BR/> <asp:checkboxlistID= "CheckBoxList1"runat= "Server"RepeatColumns= "7"> <Asp:listitemValue= "A"Text= "A"></Asp:listitem> <Asp:listitemValue= "B"Text= "B"></Asp:listitem> <Asp:listitemValue= "C"Text= "C"></Asp:listitem> <Asp:listitemValue= "D"Text= "D"></Asp:listitem> <Asp:listitemValue= "E"Text= "E"></Asp:listitem> <Asp:listitemValue= "F"Text= "F"></Asp:listitem> <Asp:listitemValue= "G"Text= "G"></Asp:listitem> </asp:checkboxlist><BR/> <asp:radiobuttonlistID= "RadioButtonList1"runat= "Server"RepeatColumns= "3"> <Asp:listitemValue= "A"Text= "A"></Asp:listitem> <Asp:listitemValue= "B"Text= "B"></Asp:listitem> <Asp:listitemValue= "C"Text= "C"></Asp:listitem> </asp:radiobuttonlist><BR/> <Asp:listboxID= "ListBox1"runat= "Server"SelectionMode= "multiple"> <Asp:listitemValue= "A"Text= "A"></Asp:listitem> <Asp:listitemValue= "B"Text= "B"></Asp:listitem> <Asp:listitemValue= "C"Text= "C"></Asp:listitem> <Asp:listitemValue= "D"Text= "D"></Asp:listitem> <Asp:listitemValue= "E"Text= "E"></Asp:listitem> </Asp:listbox><BR/> <Asp:buttonID= "Button1"runat= "Server"Text= "Reset"OnClick= "Button1_Click" />
View Code
Now write the Reset Ammonium button event, you can not copy the previous method, but need to modify, because all the customizations have implemented interface iresetcontrolable.
Dynamic Operation Demo:
All of the above controls are shown in the demo, only one, if in an Ammonium button event, for multi-control, we need to how to optimize the above program, which needs to be modified, which does not need to move. In fact, in ASP. NET development, the use of control is more opportunity to learn the object-oriented technology and knowledge.
Web control text box Reset's functionality