日期:2014-05-18  浏览次数:20419 次

偏历页面上的所有TextBox控件??
那个老鸟能告诉我怎么完成,用javascript也可以,用asp.net中的方法也可以,谢谢

------解决方案--------------------
foreach (System.Web.UI.Control control in this.FindControl( "form1 ").Controls)
{
s = control.GetType().ToString();
switch (control.GetType().ToString())
{

case "System.Web.UI.WebControls.TextBox ":
(control as TextBox).Text = " ";
break;
case "System.Web.UI.WebControls.RadioButton ":
(control as RadioButton).Checked = false;
break;
case "System.Web.UI.HtmlControls.HtmlInputText ":
(control as HtmlInputText).Value = " ";
break;
}
}

这个是我清空很多时用的
这样就可以便利所有了
------解决方案--------------------
javascript:

var inputcollect = document.getElementByTagName( "input ");
for(var i = 0; i <inputcollect.length; i++)
{
inputcollect[i].value = " ";
inputcollect[i].readonly = true;
}
------解决方案--------------------
var inputs = document.getElementsByTagName( "input ");

for (var i = 0; i < inputs.length; i++)
{
//判断是否是 <input type= "text ">
if (inputs[i].getAttribute( "type ") == "text ")
{
inputs[i].value = "hello ";
}
}