zoukankan      html  css  js  c++  java
  • asp.net中重置按钮的实现

    一 . 程序实现的方法
     
       //重置按钮事件
        protected void btn_Reset_Click(object sender, EventArgs e)
        {
            this.FindButton(this);
        }
        private void FindButton(Control c)
        {
            if (c.Controls != null)
            {

                foreach (Control x in c.Controls)
                {
                    if (x is System.Web.UI.WebControls.TextBox)
                    {
                        ((System.Web.UI.WebControls.TextBox)x).Text = "";
                    }
                    FindButton(x);
                }
            }
        }

    二. javascript 实现方法

    function ClearTextBoxValue()

    {

            for(i=0;i<window.document.forms[0].elements.length;i++)

            {

                    if(window.document.forms[0].elements[i].type=="text")         

                    {

                           window.document.forms[0].elements[i].value="";

                    }

            }

            return false;

    }
    后台调用代码如下:

    this.btnReset.Attributes.Add("onclick","return ClearTextBoxValue()");

  • 相关阅读:
    django中ckeditor富文本编辑器使用
    xadmin安装
    RabbitMQ应用示例
    windows下安装RabbitMQ
    第四章 面向对象
    第三章 模块
    git简单使用
    python中的装饰器
    Python 使用 argparse 开发命令行工具/获取命令行参数/子命令实现
    自动化运维工具 Ansible 安装、配置及使用
  • 原文地址:https://www.cnblogs.com/zhujp/p/2423414.html
Copyright © 2011-2022 走看看