Code
// Clear background, refresh page, not recommended
Foreach (Control childcontrol In This . Controls)
{
If (Childcontrol Is Textbox)
(Textbox) childcontrol). Text = "" ;
}
}
Foreach (Control childcontrol In This . Controls)
{
If (Childcontrol Is Textbox)
(Textbox) childcontrol). Text = "" ;
}
}
// Reflection:
Fieldinfo [] Infos = GetType (). getfields (bindingflags. Public | Bindingflags. nonpublic | Bindingflags. getfield | Bindingflags. instance );
For ( Int I = 0 ; I < Infos. length; I ++ )
{
If (Infos [I]. fieldtype = Typeof (Textbox ))
{
(Textbox) Infos [I]. getvalue ( This ). Text = "" ;
}
}
// The advantage of using JS is that you do not need to refresh the page:
Function clearalltextbox ()
{
VaR OBJ = Window.doc ument. Forms [ 0 ];
For (I = 0 ; I < OBJ. elements. length; I ++ )
{
VaR ELEM = OBJ. elements [I];
If (ELEM)
{
If (ELEM. Type = " Text " )
{
ELEM. Value = "" ;
}
}
}
}
//The last method is jquery.
Function cleartext (){
$ ("Input"). Each (function (){
$ (This). Val ('');
});
}