我从一个旧程序中复制了一些代码并将其复制到一个新程序中,它正在工作,但现在我的所有对象都有这个错误:
The name 'XXX' does not exist in the current context
我确定它与代码文件背后丢失与html的链接有关,但我看到的所有文件名和引用都匹配。有什么特别值得我检查的吗?提前谢谢!
来自html文件
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="garrettPenfieldUnit4.Default" %>
<。>来自.cs文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace garrettPenfieldUnit4
{
public partial class Default : System.Web.UI.Page
{
//Load events, automatically inserts todays date and selects the single king radio button
protected void Page_Load(object sender, EventArgs e)
{
arrivalDateBox.Text = DateTime.Today.ToShortDateString();
singleKingButton.Checked = true;
}
//When submit button is clicked show the two confirmation labels.
protected void submitButton_Click(object sender, EventArgs e)
{
submitLabel1.Visible = true;
submitLabel2.Visible = true;
}
//When the clear button is clicked clear the form and reset fields to their default values
protected void clearButton_Click(object sender, EventArgs e)
{
arrivalDateBox.Text = DateTime.Today.ToShortDateString();
departureDateBox.Text = String.Empty;
peopleDropDown.SelectedIndex = 0;
singleKingButton.Checked = true;
twoQueensButton.Checked = false;
singleQueenButton.Checked = false;
specialRequestsBox.Text = String.Empty;
firstNameBox.Text = String.Empty;
lastNameBox.Text = String.Empty;
addressBox.Text = String.Empty;
telephoneNumberBox.Text = String.Empty;
contactDropDown.SelectedIndex = 0;
}
}
}