客户端
<script language="javascript" type="text/javascript">
  function clearControl()
  {
        var Input=div1.getElementsByTagName("input");
       
        for(var i=0;i<Input.length;i++)
        {
        
            if(Input[i].type=="text")
            {
              
                Input[i].value="";
            }
        }
        return false;
 
  }

</script>
    <form , true);
        }
    }      
服务器端
定义一个方法做递归查找
 private void ClearControl(System.Web.UI.Control page)
    {
        int count = page.Controls.Count;
        for (int i = 0; i <count; i++)
        {
            foreach(System.Web.UI.Control con in page.Controls[i].Controls)
            {
                if(con.HasControls())
                {
                    ClearControl(con);
                }
                else
                {
                    if (con is TextBox)
                    {
                        (con as TextBox).Text = string.Empty;
                    }
                }
            }
           
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ClearControl(Page);
    }

相关文章:

  • 2021-10-31
  • 2021-10-16
  • 2021-10-22
  • 2022-02-02
  • 2022-01-03
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2021-09-15
  • 2022-12-23
  • 2021-12-05
  • 2021-09-10
  • 2021-12-19
相关资源
相似解决方案