【问题标题】:CS1061: Compilation Error Message with a Repeater ItemTemplate on <%# thisCS1061:在 <%# this 上带有中继器 ItemTemplate 的编译错误消息
【发布时间】:2019-06-25 02:25:12
【问题描述】:

我在转发器中的这段代码中收到 CS1061 错误“aspx 不包含定义”:“

这是转发器中的 ItemTemplate 部分:

<ItemTemplate>
<tr style="height:24px;" id="row_<%# DataBinder.Eval(Container.DataItem, "CourseIDString") %>" class="<%# DataBinder.Eval(Container.DataItem, "StatusClass") %>" title="<%# this.FormatStatusDesc(DataBinder.Eval(Container.DataItem, "StatusDesc") as string, (DateTime)DataBinder.Eval(Container.DataItem, "ReturnedDate"), DataBinder.Eval(Container.DataItem, "CourseIDString") as String) %>">
    <td>&nbsp;<%# this.CreateNewLink(DataBinder.Eval(Container.DataItem, "CourseIDString") as String) %></td>
</tr>
</ItemTemplate>

在此处使用 '

<%# this.FormatStatusDesc(DataBinder.Eval(Container.DataItem, "StatusDesc") as string, (DateTime)DataBinder.Eval(Container.DataItem, "ReturnedDate"), DataBinder.Eval(Container.DataItem, "CourseIDString") as String) %>">

这里:

<%# this.CreateNewLink(DataBinder.Eval(Container.DataItem, "CourseIDString") as String) %>

当我右键单击 .aspx 文件并单击查看代码时,它会进入这些方法所在的正确位置:

namespace CourseMaker
{
    public partial class CourseTemplate_2 : System.Web.UI.Page
    {
        public String FormatStatusDesc(string statusdesc, DateTime rdt, String courseID{}

        public String CreateNewLink(String childCourseID){}
}

页面指令:

<%@ Page Title="" Language="C#" MasterPageFile="~/CourseTemplate_NoAcYear.master" AutoEventWireup="true" CodeBehind="CourseTemplate_2.aspx.cs" Inherits="CourseMaker.CourseTemplate_2" %>

当我输入“

public void btn_new_child_onclick(object sender, EventArgs e)

但是当我在页面后面的代码中添加新方法时,这些方法不会显示在智能感知列表中。

我尝试了以下方法,但编译器仍然显示相同的错误: 1)清理并重建解决方案 2)清除所有bin文件夹的内容然后重建 3)从项目中删除文件并重新创建它们 4) 在 webconfig 文件中添加了 'optimizeCompilations="false"'

此代码过去一直正常工作,但有些地方发生了变化,我只是不确定是什么。非常感谢任何帮助。

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    在搜索错误消息“无法导航到插入符号下的符号”后,当我在 this.FormatStatus 行上尝试“转到定义”时,我发现了这篇文章: Go To Definition: "Cannot navigate to the symbol under the caret."

    对我有用的答案是关闭 VS,删除 .vs 文件夹,打开 VS 并重建项目,错误消失了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-07
      • 2016-06-30
      • 2011-01-02
      • 2016-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多