// Clear the background and refresh the page. It is 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 = "";
}
}
// Use 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 objdomainmetadata 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 = "";
}
}
}
}
// Use jquery
Function cleartext (){
$ ("Input"). Each (function (){
$ (This). Val ('');
});
}
Clear all textbox