标签在当前上下文中不存在
|
为什么收到此错误“名称“'lblHelloWorld \”在当前上下文中不存在”?我如何解决它?
<%@ Page Language=\"C#\" AutoEventWireup=\"True\" Inherits=\"_Default\" Codebehind=\"Default.aspx.cs\" %>
<!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 id=\"Head1\" runat=\"server\">
<title>Hello, world!</title>
</head>
<body>
<form id=\"form1\" runat=\"server\">
<asp:ScriptManager ID=\"MainScriptManager\" runat=\"server\" />
<asp:UpdatePanel ID=\"pnlHelloWorld\" runat=\"server\">
<ContentTemplate>
<asp:Label runat=\"server\" ID=\"lblHelloWorld\" Text=\"Click the button!\" />
<br /><br />
<asp:Button runat=\"server\" ID=\"btnHelloWorld\" OnClick=\"btnHelloWorld_Click\" Text=\"Update label!\" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ajaxTesting
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnHelloWorld_Click(object sender, EventArgs e)
{
lblHelloWorld.Text = \"Hello, world - this is a fresh message from ASP.NET AJAX! The time right now is: \" + DateTime.Now.ToLongTimeString();
}
}
}
我尝试清洁和重新铺砌;删除designer.cs文件并重新创建它,但没有用。
没有找到相关结果
已邀请:
7 个回复
雄鞋谋塘
文件中存在问题。请尝试在designer.cs文件中为此标签手动添加参考。 编辑: 修改代码后的问题在is3中。 要解决您的问题,请执行以下操作: 用以下内容替换行:
焙恍挝厂熄
页面。 将“ 7”标签替换为您复制的标签 同样,也从
文件复制并粘贴代码。 我认为这应该可以解决您的问题。
捅瓶啡
剃摧庭峨僳
细屠截殴些
蹄渭信妥扳
提孺局缎