大家进来研究,有关is的问题?
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
foreach(System.Web .UI .Control ct in this.Controls )
{
TextBox tb;
if (ct is TextBox)
{
tb=(TextBox)ct;
Label1.Text =tb.Text+" " ;
}
}
}
}
问题:为何Label1.Text总是为空呢?跟踪了一下,其中if (ct is TextBox)中总是为false;调试无错误。