Asp.Net清除页面上所有的TextBox的值.

foreach (Control c in this.FindControl("form1").Controls)
{
    if (c is TextBox)
    {
        ((TextBox)c).Text = "";
    }
}

 

用JavaScript清除页面上所有TextBox的值

<script language="javascript" type="text/javascript">
        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 = "";
                    }
                } 
            } 
        }
    </script>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案