输入栏位清除 [英] Input field clear
本文介绍了输入栏位清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我以一种形式拥有100多个不同的输入字段.将所有输入数据插入数据库后.我应该清除所有输入字段,因为我要为每个输入字段分配空值,我认为将空值分配给100字段是一个漫长的过程.有没有清除所有输入字段的简单方法?
Hi
i have above 100 different input field in one form. After inserting all the input data into database . i should clear all the input fields for that i am assigning null value for each input field i think it lengthy process assigning null value to 100 field . is there any simple process for clearing all the input fields ?
推荐答案
foreach (Control item in this.Controls)
{
if (item is textBox)
{
(item as TextBox).Text = "";
}
}
private void ClearTextBoxes(Control parent)
{
if (parent is TextBox)
{
(item as TextBox).Text = "";
}
else
{
if (parent.Controls.Count > 0)
{
foreach (Control item in parent.Controls)
{
ClearTextBoxes(parent);
}
}
}
}
像这样调用该方法:
Call that method like so:
foreach (Control item in this.Controls)
{
ClearTextBoxes(item);
}
看看这个提示/技巧: ^ ]
其中提到的3种方法可用于执行相同操作.选择一个您喜欢的人.
Have a look at this Tip/Trick: Simple and easy way to clear all the input fields in the form.[^]
There are 3 ways mentioned in it that can be used to do the same. Pick the one you like.
您可以使用javascript.我不清楚,但form.clear()已用完.搜索.
You can use javascript . I am not clear but form.clear() is use full. Search on that.
这篇关于输入栏位清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文