首页 > 解决方案 > 我的 ASP 控件 ID 没有出现在页面后面的代码中 (C#) 如何解决这个错误?

问题描述

即使我一次又一次地重建解决方案,我的 ASP 控件 ID 也没有显示在页面后面的代码 (C#) 中。ASP 的第一行开头是:

蓝色下划线

有蓝色下划线。我正在提供此错误的图片。请帮助我解决这个问题。谢谢

TextBox 控件 ID C# 页面错误

标签: c#asp.netwebforms

解决方案


你可以试试这个:

foreach (Control panelctrl in UpdatePanel1.ContentTemplateContainer.Controls)
{
    if (panelctrl is Panel)
    {
        Panel p = (Panel)panelctrl;
        foreach (Control txt in p.Controls)
        {
            if (txt is TextBox)
            {
                TextBox txtBox = (TextBox)txt;
                // do something with textbox
            }
        }
    }
}

推荐阅读