Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionLink CS1026: ) expected

I get the above error whenever I try and use ActionLink ? I've only just started playing around with MVC and don't really understand what it's problem is with the code (below):

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

This just seems to be a parsing issue but it only happens when I run the page. The application builds perfectly fine, so I really don't get it because the error is a compilation error? If I take line 25 out it will happen on the next line instead...

 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 
like image 978
John_ Avatar asked Dec 13 '08 17:12

John_


3 Answers

Remove the semi-colon from the ActionLink line.

Note: when using <%= ... %> there's no semi-colon and the code should return something, usually a string. When using <% ...; %>, i.e. no equals after the percent, the code should return void and you need a semi-colon before the closing percent.

When using Html methods, for example, VS intellisense will tell you whether it returns void. If so, don't use an equals and terminate with a semi-colon.

like image 169
Mike Scott Avatar answered Oct 21 '22 10:10

Mike Scott


Use it without trailing semicolon:

<%= Html.ActionLink("Lists", "Index", "Lists") %>
like image 39
maxnk Avatar answered Oct 21 '22 11:10

maxnk


In my case, I really missed ) at the end of ActionLink.

<%= Url.Action("SearchPatientSchedules", "PatientSchedules" **)** %>
like image 34
Amel Music Avatar answered Oct 21 '22 11:10

Amel Music