Thursday, April 21, 2011

How to reset web form "CONTROL in ASP.NET" after save data

//call this function after completion of  insert query
 ClearInputs(Page.Controls);

 private void ClearInputs(ControlCollection ctrls)
    {

        foreach (Control ctrl in ctrls)
        {

            if (ctrl is TextBox)
            {
                ((TextBox)ctrl).Text = string.Empty;


            }
            else if (ctrl is DropDownList)
            {
                ((DropDownList)ctrl).ClearSelection();

            }

            ClearInputs(ctrl.Controls);

        }

    }

0 comments:

Post a Comment