Error Message displayed as "AddFavoriteRadWindow not found"
我的代码:
protected void btnAddReport_Click(object sender, ImageClickEventArgs e)
{
this.form1.Controls.Add(AddFavoriteRadWindow); // working fine
}
protected void btnOk_Click(object sender, EventArgs e)
{
if (txtReportFavorite.Text != string.Empty)
{
// code for inserting into db..
AddFavoriteRadWindow.Visible = false; // not working
}
}
当我想隐藏rad窗口时,会显示“AddFavoriteRadWindow not found”消息
答案 0 :(得分:0)
您需要从Control Collection中获取添加的控件的实例。尝试
(this.form1.FindControl(AddFavoriteRadWindow.ID) as RadWindow).Visible = false;
您可以针对null进行检查。就像是。
if((this.form1.FindControl(AddFavoriteRadWindow.ID) as RadWindow) != null)
(我不确定您的班级名称,我使用了RadWindow
,但您可以将其替换为您的班级名称)
编辑:您应该在FindControl方法中传递控件的字符串id
以获取该特定控件