Label1在当前上下文中不存在 [英] Label1 does not exist in the current context

查看:215
本文介绍了Label1在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计页面(default.aspx)这样控制。

 <   asp:label     id   =  label1    runat   = 服务器 >  
< / asp:label > ;





.aspx.cs这样的页面



 label1.text = session [emp]; 



我的问题是我在设计页面上有标签控制但是.aspx.cs页面出现label1剂量当前上下文中不存在。这是错误。



纠正此错误。如何解决。



请帮帮我。

解决方案

而不是你的代码:

 <   asp:label     id   =  label1    runat   =  server >  
< / asp:标签 >



使用此项:

 <   asp:标签    id   =  Label1    runat   = 服务器 >  <   / asp:标签 >  



我用这条线进行了测试,效果很好:

 Label1.Text =   CodeProject; 


design page(default.aspx) control like this.

<asp:label id="label1" runat="server">
</asp:label>



.aspx.cs page like this

label1.text=session["emp"];


my probelm is i have label control on design page but .aspx.cs page appears label1 dose not exist in the current context.this is error.

rectify this error.how is it solve.

please help me.

解决方案

Instead of your this code :

<asp:label id="label1" runat="server">
</asp:label>


Use this one :

<asp:Label id="Label1" runat="server"></asp:Label>


I tested it with this line and it works good :

Label1.Text = "CodeProject";


这篇关于Label1在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆