您的位置:首页技术开发JAVA Script → 如何快速清除所有TextBox的值

如何快速清除所有TextBox的值

时间:2010/1/28 12:47:00来源:本站整理作者:我要评论(0)

C#代码

public static void SetControlReadOnly(Control ctr)
        {
           
if (ctr is TextBox)
            {
                TextBox txtControl
= (TextBox)ctr;
                txtControl.ReadOnly
= true;
                txtControl.Enabled
= false;

            }
           
else if (ctr is RadioButton) { RadioButton btn = (RadioButton)ctr;
                btn.Enabled
= false;

            }
           
else if (ctr is Button)
            {
                Button btn
= (Button)ctr;
                btn.Enabled
= false;

            }
           
else if (ctr is FileUpload)
            {
                FileUpload btn
= (FileUpload)ctr;
                btn.Enabled
= false;

            }  
           
else if (ctr is RadioButtonList)
            {
                RadioButtonList btn
= (RadioButtonList)ctr;
                btn.Enabled
= false;
            }

           
else if (ctr is CheckBox)
            {
                CheckBox cb
= (CheckBox)ctr;
                cb.Enabled
= false;
            }
           
else if (ctr is CheckBoxList)
            {
                CheckBoxList cb
= (CheckBoxList)ctr;
                cb.Enabled
= false;
            }
           
else if (ctr is DropDownList)
            {
                DropDownList list
= (DropDownList)ctr;
                list.Enabled
= false;
            }

           
else if (ctr is HtmlTextArea)
            {
                HtmlTextArea cb
= (HtmlTextArea)ctr;
                cb.Attributes.Add(
"readonly", "");
                cb.Disabled
= true;
            }
           
else if (ctr is HtmlSelect)
            {
                HtmlSelect rb
= (HtmlSelect)ctr;
                rb.Disabled
= true;
            }

           
else if (ctr is HtmlInputCheckBox)
            {
                HtmlInputCheckBox rb
= (HtmlInputCheckBox)ctr;
                rb.Disabled
= true;
            }
           
else if (ctr is HtmlInputRadioButton)
            {
                HtmlInputRadioButton rb
= (HtmlInputRadioButton)ctr;
                rb.Disabled
= true;
            }
           
else if (ctr is HtmlInputText)
            {
                HtmlInputControl input
= (HtmlInputControl)ctr;
                input.Attributes.Add(
"readonly", "");
                input.Disabled
= true;
            }
            
else if (ctr is HtmlInputFile)
            {
                HtmlInputFile input
= (HtmlInputFile)ctr;
                input.Attributes.Add(
"readonly", "");
                input.Disabled
= true;
            }
               
           
else
               
foreach (Control ctr1 in ctr.Controls)
                {
                    SetControlReadOnly(ctr1);
                }
        }

JS代码

因为textbox和HtmlInputText在客户端生成出来就是textarea和input[type=text],只要用js清除这两种标签的值就可以了

document.getElementsByName('text')

 

相关阅读 我的世界手机版药水插件 我的世界手机版药水jsnode.js环境搭建教程 node.js怎么进行环境搭建我的世界手机版js函数表大全JS文件中的中文在网页上显示为乱码解决方法(带缩略图版)JS图片切换代码js鼠标滑过切换层效果代码下载jsp统计在线人数代码jsp技巧大全

文章评论
发表评论

热门文章 JS文件中的中文在网页

最新文章 JS文件中的中文在网页关于一些Play 1.0.1资 JAVA中抽象类与接口的区别Java技巧:关于Cookie的操作JAVA AWT图形用户界面设计巧用Java将Word转换为Html网页文件

人气排行 JS文件中的中文在网页上显示为乱码解决方法怎么为Java程序添加漂亮背景图片代码JAVA AWT图形用户界面设计怎样获取java线程中信息JS简介及特点Java面向对象编程学习总结js鼠标滑过切换层效果代码下载教你java使用回调和线程处理响应全过程