代码之家  ›  专栏  ›  技术社区  ›  John_

ActionLink CS1026:)预期为

  •  11
  • John_  · 技术社区  · 17 年前

    <%= Html.ActionLink("Lists", "Index", "Lists"); %>
    

    这似乎是一个解析问题,但只有在我运行页面时才会发生。应用程序构建得非常好,所以我真的不明白,因为这个错误是编译错误?如果我把第25行拿出来,它会发生在下一行。。。

     Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
    
    Compiler Error Message: CS1026: ) expected
    
    Source Error:
    
    Line 23:   </div>
    Line 24:   
    Line 25:   <%= Html.ActionLink("Lists", "Index", "Lists"); %>
    Line 26:   <a href="<%= Url.Action("/", "Lists"); %>">Click here to view your lists</a>
    Line 27:   
    
    
    Source File: d:\Coding\Playground\HowDidYouKnowMVCSoln\HowDidYouKnowMVC\Views\Home\Index.aspx    Line: 25 
    
    3 回复  |  直到 17 年前
        1
  •  25
  •   Mike Scott    17 年前

    从ActionLink行中删除分号。

    <%= ... %> 没有分号,代码应该返回一些东西,通常是字符串。使用时 <% ...; %> ,即百分比后不等于,代码应返回void,并且在结束百分比前需要分号。

        2
  •  5
  •   maxnk    17 年前

    使用时不带尾随分号:

    <%= Html.ActionLink("Lists", "Index", "Lists") %>
    
        3
  •  2
  •   Amel Music    15 年前

    在我的例子中,我真的错过了ActionLink结尾的第二段。

    <%= Url.Action("SearchPatientSchedules", "PatientSchedules" **)** %>