Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在附加了Id My Code的网页上启用按钮Asp.net?_C#_Asp.net_.net - Fatal编程技术网

C# 如何在附加了Id My Code的网页上启用按钮Asp.net?

C# 如何在附加了Id My Code的网页上启用按钮Asp.net?,c#,asp.net,.net,C#,Asp.net,.net,我正在尝试通过提供其id来启用按钮,就像我在页面上为所有按钮进行了diabling一样,我们如何为具有id的特定按钮执行操作我的代码是 public static void EnableInsertBtn(Control parent) { foreach (Control B in parent.Controls) { if (B.GetType() == typeof(Button)) { ((Button)(B)).

我正在尝试通过提供其id来启用按钮,就像我在页面上为所有按钮进行了diabling一样,我们如何为具有id的特定按钮执行操作我的代码是

public static void EnableInsertBtn(Control parent)
{

    foreach (Control B in parent.Controls)
    {
        if (B.GetType() == typeof(Button))
        {
            ((Button)(B)).Enabled = false;

        }
        if (B.HasControls())
        {
            EnableInsertBtn(B);
        }

    }
希望你的建议


谢谢

尝试使用按钮本身的ID禁用按钮

btnID.Enabled = false;
使能

btnID.Enabled = true;