1

您好,我正在使用它来获取控件的值,但控件集合为空:

        Type type = BuildManager.GetCompiledType("~/Default.aspx");

        Page pageView = (Page)Activator.CreateInstance(type);

        Label lbl1 = (Label) pageView.FindControl("lbl1");

        string lbl1Value = lbl1.Text;

如果在 Visual Studio 中添加快速手表,我可以看到 PageView.Context 具有标签的值,但 PageView.Context 受到保护,所以我不知道如何在运行时访问它

4

1 回答 1

1

我已经解决了这个问题,页面在反射期间不显示控件值,因为我设置了属性 autoevent wireup=false

于 2013-05-27T19:59:05.787 回答