标签:io os 使用 ar for art sp cti on
//后台清空,刷新页面,不推荐
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 = "";
}
}
//用反射:
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 = "";
}
}
//使用js,好处是不用刷新页面:
function ClearAllTextBox()
{
var obj=window.document.forms[0];
for(i=0;i<obj.elements.length; i++)
{
var elem=obj.elements[i];
if(elem)
{
if(elem.type=="text")
{
elem.value="";
}
}
}
}
//最后一种用Jquery
function ClearText() {
$("input").each(function() {
$(this).val(‘‘);
});
}
标签:io os 使用 ar for art sp cti on
原文地址:http://www.cnblogs.com/lschenblog/p/3979939.html