Search This Blog

Friday, October 30, 2009

Reset the Controls In recursive fashion

protected void btnReset_Click(object sender, EventArgs e)
    {
        cleanFields(this);
    }
 
    protected void cleanFields(Control container)
    {
        foreach (Control c in container.Controls)
        {
            if (c is TextBox)
            {
                ((TextBox)c).Text = string.Empty;
            }
            if (c is DropDownList)
            {
                ((DropDownList)c).SelectedIndex = 0;
            }
            if (c is RadioButtonList)
            {
                ((RadioButtonList)c).ClearSelection();
            }
            this.cleanFields(c);
        }
        pnlConferenceCall.Visible = false;
        pnlParticipants.Visible = false;
    }

No comments:

Post a Comment