我有一个函数应该清除/重置我的aspx.page中的所有文本框,并且此页面使用母版页但它不起作用。下面是代码。刚刚从这个网站获得这个代码。重置/清除所有文本框功能不起作用
//Clear all textbox
ResetTextBoxes(this);
//function to clear textboxes
private void ResetTextBoxes(Control parent)
{
if (parent is TextBox)
{
((TextBox)parent).Text = string.Empty;
}
foreach (Control child in parent.Controls)
{
if (child is TextBox)
{
((TextBox)child).Text = string.Empty;
}
ResetTextBoxes(child);
}
}
你是怎么调用ResetTextBoxes的,在这种情况下是什么? –
(this)是包含控件的页面。 –