如何访问 ascx 控件的代码隐藏对象中的 public 变量? (内联表达式)

How do I access a public variable in the codebehind object for an ascx control? (Inline Expression)

这曾经有效(在网站项目上)。现在,我们正在转换为 Web 应用程序项目,但我似乎无法让它工作。

非常简单的 ascx,上面什么都没有,并在 cs 文件中创建了一个 public class 变量。

这是cs文件中的部分代码

public partial class Test: System.Web.UI.UserControl
{
    public string strThisOne = "This is the string";

    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

现在在 ascx 文件中编写代码(这曾经有效,我还缺少什么?):

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="test.ascx.cs" Inherits="test" %>
<%= strThisOne %>

我现在收到一条错误消息,指出 strThisOne 在当前上下文中不存在。什么改变了?以及我如何继续访问变量(我们过去经常使用这种技术将值输入页面上的 JavaScript)?

好的。因此,Visual Studio 在编辑器 window 中将此显示为错误(带有红色波浪下划线),但是当我编译时没有错误并且页面正常工作!似乎是 Intellisense 的问题...