asp.net 对象引用未设置错误
我试图从 aspx 页面找到标签控件。
Label labelmessageupdate;
labelmessageupdate = (System.Web.UI.WebControls.Label )FindControl("updateMessage1");
如果我设置 labelmessageupdate.Text ="something"
它会返回对象引用异常。
并且标签控件位于更新面板内,这可能是问题所在。
I am trying to find the label control from aspx page.
Label labelmessageupdate;
labelmessageupdate = (System.Web.UI.WebControls.Label )FindControl("updateMessage1");
if i set labelmessageupdate.Text ="something"
it returns object reference exception.
and the label control is within the update panel could that be the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需检查是否为空。始终检查 null 条件,以免最终显示对象引用错误。
Just check for null. Always check null condition so that it doesn't end up showing Object Reference error.
我认为它无法找到您指定的标签控件
I think its not able to find the label control you specified
试试这个,您尝试查找的控件可能位于另一个用户控件中。
使用
Try this, and the control your trying to find could be in a another user control.
To use