저는 ASP C# 서적과 튜토리얼을 진행할 것입니다. 그러나 나는 문제가 발생했습니다. 몇 가지 이벤트를 나열하는 다음 코드가 있습니다.ASP.eventtracker_aspx '에 정의가 없습니다.
EventTracker.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EventTracker.aspx.cs" Inherits="EventTracker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Event Tracker</title>
<style type="text/css">
h1
{
font-size: large;
}
</style>
</head>
<body>
<form id="Form1" runat="server">
<div>
<h1>Controls being monitored for change events:</h1>
<asp:TextBox ID="txt" runat="server" AutoPostBack="true"
OnTextChanged="CtrlChanged" />
<br /><br />
<asp:CheckBox ID="chk" runat="server" AutoPostBack="true"
OnCheckedChanged="CtrlChanged"/>
<br /><br />
<asp:RadioButton ID="opt1" runat="server" GroupName="Sample"
AutoPostBack="true" OnCheckedChanged="CtrlChanged"/>
<asp:RadioButton ID="opt2" runat="server" GroupName="Sample"
AutoPostBack="true" OnCheckedChanged="CtrlChanged"/>
<br /><br /><br />
<h1>List of events:</h1>
<asp:ListBox ID="lstEvents" runat="server" Width="355px"
Height="305px" /><br />
</div>
</form>
</body>
</html>
EventTracker.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class EventTracker : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Log("<< Page_Load>>");
}
protected void Page_PreRender(object sender, EventArgs e)
{
//Find the control ID of the sender.
//This requires converting the Object type into a control class.
string ctrlName = ((Control)sender).ID;
Log(ctrlName + " Changed");
}
protected void Log(string entry)
{
lstEvents.Items.Add(entry);
//Select the last item to scroll the list so the most recent are visible
lstEvents.SelectedIndex = lstEvents.Items.Count - 1;
}
}
나는 다음과 같은 오류 잡 오전 :
Error 1 'ASP.eventtracker_aspx' does not contain a definition for 'CtrlChanged' and no extension method 'CtrlChanged' accepting a first argument of type 'ASP.eventtracker_aspx' could be found (are you missing a using directive or an assembly reference?)
내가 ASP에 새로운 오전 이해하려는를 왜 그런 오류가 발생했는지 나중에 참조 할 때 무엇이 원인인지 알 수 있습니다. 마크 업에서