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
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.
Use it without trailing semicolon:
<%= Html.ActionLink("Lists", "Index", "Lists") %>
In my case, I really missed ) at the end of ActionLink.
<%= Url.Action("SearchPatientSchedules", "PatientSchedules" **)** %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With