我似乎在Visual Studio 2012中遇到了一個問題,其中收到21個錯誤,說明名稱(ddlstud,hidId,txtName,txtCoverImage,txtReldate,gvVidGame)不存在於當前的情況下。我有我的default.aspx文件設置爲從我的default.aspx.cs文件中讀取。在當前上下文中不存在名稱「___」
這裏是我的Default.aspx文件
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="True" CodeBehind="Default.aspx.cs" Inherits="VideoGameWiki._Default" %>
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:GridView ID="gvVidGame" runat="server"></asp:GridView><br />
<asp:Label ID="lblName" runat="server" Text="Name: "></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Label ID="lblStud" runat="server" Text="Studio: "></asp:Label>
<asp:DropDownList ID="ddlStud" runat="server"></asp:DropDownList><br />
<asp:Label ID="lblReldate" runat="server" Text="Release date: "></asp:Label>
<asp:TextBox ID="txtReldate" runat="server"></asp:TextBox><br />
<asp:Label ID="lblCoverImage" runat="server" Text="Cover Image: "></asp:Label>
<asp:TextBox ID="txtCoverImage" runat="server"></asp:TextBox><br />
<asp:Label ID="lblDescr" runat="server" Text="Description: "></asp:Label>
<asp:TextBox ID="txtDescr" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add" />
<br />
<asp:Button ID="btnNext" runat="server" Text="Next" OnClick="btnNext_Click" />
<input runat="server" id="hidId" type="hidden" />
<asp:Button ID="btnPrev" runat="server" OnClick="btnPrev_Click" Text="Prev" />
<asp:Button ID="Btn_delete" runat="server" Text="Delete" />
</asp:Content>
,這裏是我的default.aspx.cs文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VideoGameWiki
{
public partial class _Default : System.Web.UI.Page
{
private VideoGamesWikiContainer entities = new VideoGamesWikiContainer();
private int currentId = 0;
}
}
(編輯)這是我的設計師。 cs文件,因爲建議的方法不能很好地工作。
namespace VideoGameWiki {
public partial class _Default : System.Web.UI.Page
{
/// <summary>
/// gvVidGame control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvVidGame;
任何幫助,將不勝感激!
如果所有元素都已正確添加,請檢查您的設計器文件([page] .designer.cs) – RononDex
您試過Ctrl + Shift + F + txtCoverImage(整個解決方案)嗎? –
請使用這裏的代碼標記,而不是發佈一個鏈接到pastebin。 –