이 오류가 발생합니다. "이름 '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();
}
}
}
나는 청소 rebuliding 시도; designer.cs 파일을 삭제하고 다시 만들었지 만 사용하지 못했습니다.
그리고 Label을 UpdatePanel 외부에 배치하면 작동합니까? –
아니요 아직 작동하지 않습니다 – vatspoo
답변 [여기] (http://forums.asp.net/t/1006588.aspx/1?The+name+xxx+Does+Not+Exist+in+the+Current? + Context)도 문제를 해결할 수 있습니까? –