Saturday, 31 March 2012

How to clear control in webpages?


            foreach (Control item in this.form1.Controls)
            {
             
               
                if (item is TextBox)
                {
                    TextBox t = (TextBox)item;
                    t.Text = "";
                }
                else if(item is ListControl)
                {
                    // all list controls are cleared ,rblist,checkboxlist,listbox,Dorpdownlist
                    ListControl li = (ListControl)item;
                    li.Items.Clear();
                   
                }

            }

No comments:

Post a Comment