C# 如何使用单击事件更改标签文本
我在site.Master(asp.net)中有一个名为“lblnotify”的标签C# 如何使用单击事件更改标签文本,c#,asp.net,mouseclick-event,C#,Asp.net,Mouseclick Event,我在site.Master(asp.net)中有一个名为“lblnotify”的标签 *Response.Write("Exception Occured: " + er);* notificationManager在另一个类的submit按钮中触发 *protected void btnSubmit_Click(object sender, EventArgs e) { appSite call = new appSite();
*Response.Write("Exception Occured: " + er);*
notificationManager在另一个类的submit按钮中触发
*protected void btnSubmit_Click(object sender, EventArgs e)
{
appSite call = new appSite();
call.notificationManager();
}*
*Response.Write("Exception Occured: " + er);*
但这给了我错误对象引用未设置为
*string i = lblnotify.Text;*
*Response.Write("Exception Occured: " + er);*
在try块中,当我注释try catch时,在
*Response.Write("Exception Occured: " + er);*
在catch块中,当我不注释时,请尝试catch。我已经尽了我所能,但仍然得到了错误。非常感谢您的帮助。我不知道您要做什么!,但控件在初始页生命周期中初始化,
*Response.Write("Exception Occured: " + er);*
您唯一能做的就是在page类的构造函数中初始化label控件:
*Response.Write("Exception Occured: " + er);*
public appSite()
{
lblnotify = new Label();
}
Label1.Text=(i.ToString())的这个kine是什么;我是一根绳子。。为什么要尝试?感谢您的回复,刚刚编辑了与notificationManager()在同一页面中的outis lblNotify?@matzone,lblNotify在asp.net页面中,而notificationManager()在asp.net页面的c#页面中-页面后面的代码用于回复。当a使用新关键字时,我没有收到任何错误,但是lblnotify的文本没有更改。如果您想将值发送到另一个页面,您应该使用queryString或SessionState并在页面加载事件中设置文本框值,我想您应该阅读更多关于web技术的信息,特别是asp.net:)