So I'm attempting to convert a website project to a web application project. I created the new web application project, moved over the files, created and populated the designer files for each ASPX and ASCX file, and included those files. Once done I ran through and corrected some smaller things here and there but all is good... except a few user controls.

So I have user controls with things like <%=Message %> in them which corresponds to a public property in the code behind class. Visual Studio now says "The name 'Message' does not exist in the current context." I've tried everything from making a new control and retyping the code to trying the newer <%: shorthand tag. Nothing seems to allow VS to "see" the property.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DoubleHrBanner.ascx.cs" Inherits="Test.ctrl.misc.DoubleHrBanner" %>

<hr class="faded" />
<span><%=Message %></span>
<hr class="faded"  />

and

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Test.ctrl.misc
{
  public partial class DoubleHrBanner : System.Web.UI.UserControl
  {
    public string Message = "";
    public int Count = 0;
  }
}
1

There are 1 answers

3
Licht On

I forgot to update this quite some time ago. So for anyone facing a similar situation I would give you two bits of information.

  1. If you're looking for the Convert To Web Application button in VS2013, it's been moved from the context menu. Select your item to convert in the Solution Explorer and then click Project>Convert To Web Application at the top of VS.

  2. If you have >300 compiler errors following the conversion and VS is throwing a huge fit about inline code, just ignore it. Fix all other errors first and once all the code behind and dependent code behind (such as user controls inside user controls) and VS will eventually get itself together and stop throwing errors on your inline code for no reason.