偏历页面上的所有TextBox控件

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;
}

posted on 2008-08-12 17:28  草原和大树  阅读(309)  评论(3编辑  收藏  举报