一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp.net 遍历指定的控件类型 设置为只读

时间:2013-05-08 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码

protected void TurnControlsReadOnly()

{

    foreach (Control obj in form1.Controls)

    {

        if (obj is TextBox)

        {

            //obj.Attributes.Add("readonly", "true");

            ((TextBox)obj).ReadOnly = true;

        }

    }

    foreach (Control obja in form1.Controls)

    {

        if (obja is DropDownList)

        {

            ((DropDownList)obja).Enabled = false;

        }

    }

    foreach (Control objb in form1.Controls)

    {

        if (objb is Button)

        {

            ((Button)objb).Visible = false;

            ((Button)objb).Enabled = false;

 

        }

    }

    foreach (Control obja in form1.Controls)

    {

        if (obja is RadioButtonList)

        {

            ((RadioButtonList)obja).Enabled = false;

        }

    }

 

    dropSort.Enabled = false;

    //btnUPloadIma.Visible = false;

    ddlCategory.Enabled = true;

    btnSaveCategory.Visible = true;

    btnSaveCategory.Enabled = true;

    txtOtherCategory.ReadOnly = false;

    txtSortOther.ReadOnly = true;

 

    for (int i = 0; i < dlstProductImage.Items.Count; i++)

    {

        dlstProductImage.Items[i].FindControl("lbtnDelete").Visible = false;

    }

    fldBuyInfoImage.Visible = false;

}

热门栏目