Label.Text对当前上下文不存在 [英] Label.Text does not exist to the current context
本文介绍了Label.Text对当前上下文不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我的网站asp.net c#project我有以下代码
Hi guys in my website asp.net c# project I have the following code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PDTSuccess.aspx.cs" Inherits="FurSiteMs.PDT.PDTSuccess" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>Personalized 'Thank you' for customer:</b><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br /><br />
<b>PDT Response</b><br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
和c#文件
and in c# file
namespace FurSiteMs.PDT
{
public partial class PDTSuccess : System.Web.UI.Page
{
....
Label2.Text =你好;
但我收到一条错误消息当前不存在Label2内容内容。
我尝试删除我的designer.cs文件,但没有...我尝试删除它完整,也没有...
我还有什么办法可以解决这个问题?
Thnx提前为你服务帮助和你的时间!
....
Label2.Text="hello";
but I receive an error message Label2 content does not exist to the current content.
I try to delete my designer.cs file but nothing... I try to remove it complete and also nothing..
what else i shoul try in order to solve the problem?
Thnx in advance for your help and your time!
推荐答案
经过大量的Hit and Trial,最后OP(JasonTsoum77
)创建了一个来自Scratch的新Web表单并再次添加了标签。
令人惊讶的是,它起作用并且问题得到了解决。 :)
After a lot of Hit and Trial, finally OP (JasonTsoum77
) created a new Web Form from the Scratch and added the Labels again.
Surprisingly, it worked and issue is solved. :)
你好,
除了重做你的床单之外,我唯一能想到的就是你没有输入Label2在CS文件中的正确位置。我会尝试创建一个方法并将Label2放在那里。希望这会有所帮助!
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e );
Label2.Text =你好世界;
}
Hi,
The only thing I can think of besides redoing your sheets is maybe you are not typing the Label2 in the correct place in the CS file. I would try creating a method and placing the Label2 in there. Hope this helps!
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Label2.Text = "hello world";
}
这篇关于Label.Text对当前上下文不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文