common.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Test_1
{
    public class common
    {
        public static void clear_Control(ControlCollection controls)
        {
            foreach(Control ctrl in controls)
            {
                if (ctrl is TextBox)
                {
                    ((TextBox)ctrl).Text = "";
                }
                else if (ctrl is RadioButtonList)
                {
                    ((RadioButtonList)ctrl).ClearSelection();
                }
                else if (ctrl is DropDownList)
                {
                    ((DropDownList)ctrl).ClearSelection();
                }
            }
           
        }

        public static void Inactive_Controls(ControlCollection controls)
        {
            foreach (Control ctrl in controls)
            {
                if (ctrl is TextBox)
                {
                    ((TextBox)ctrl).Enabled = false;
                }
                else if (ctrl is RadioButtonList)
                {
                    ((RadioButtonList)ctrl).Enabled = false;
                }
                else if (ctrl is DropDownList)
                {
                    ((DropDownList)ctrl).Enabled = false;
                }
                else if (ctrl is Button)
                {
                    ((Button)ctrl).Enabled = false;
                }
            }
        }

        public static void Active_Controls(ControlCollection controls)
        {
            foreach (Control ctrl in controls)
            {
                if (ctrl is TextBox)
                {
                    ((TextBox)ctrl).Enabled = true;
                }
                else if (ctrl is RadioButtonList)
                {
                    ((RadioButtonList)ctrl).Enabled = true;
                }
                else if (ctrl is DropDownList)
                {
                    ((DropDownList)ctrl).Enabled = true;
                }
                else if (ctrl is Button)
                {
                    ((Button)ctrl).Enabled = true;
                }
            }
        }

    }
}

Comments

Popular posts from this blog

webformaspx