Question

I recently upgraded my Visual Studio project from 2008 to 2012. After the upgrade I now get errors on all of the variables that previously worked in my C# file.

The name 'ddlVariable' does not exist in the current context...

A sample of my ASPX file:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="mycode.aspx.cs" Inherits="myNameSpace.DoStuff" Title="Do Something" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <div style="clear: both; padding-top: 20px">
            <span style="float: left; width:125px">Some Words:</span>
            <asp:DropDownList ID="ddlVariable" runat="server" Width="224px"/>
        </div>
    </asp:Content>

And my corresponding C# file:

namespace myNameSpace
{
    public partial class DoStuff : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsTrue)
            {
                // Populate Title drop down list
                ddlVariable.DataSource = Class.getInfo();

            }
        }
    }
}

Any help on this would be greatly appreciated. I have spent many hours trying to get my project working.

Thanks

Was it helpful?

Solution

your aspx.designer.cs file may be corrupted.

Delete the corrupted aspx.designer.cs file form physical folder

Right click your Project file and select “Convert to Web Application“. I will generate new aspx.designer.cs.

enter image description here

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top