Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.ActionLink does not display anything

I have this simple snippet with an ActionLink that is supposed to display some text as a link, but it's not working.

Here's the code snippet.

<div id = "Div1">
        <table id = "Table1">
            <% while ((category = SomeNamespace.Helper.GetNextCategory(categoryIndex++)) != null)
               { %>
                <tr>
                    <td class = "catalogCell">
                        <% Html.ActionLink(category.Name, 
                               "DisplayCategory", 
                               "Catalog"); %>
                    </td>
                </tr>
            <% } %>
        </table>
    </div>
like image 546
Water Cooler v2 Avatar asked Aug 15 '26 14:08

Water Cooler v2


2 Answers

You need an = sign:

<%= Html.ActionLink(category.Name, 
                    "DisplayCategory", 
                    "Catalog") %>
like image 149
D'Arcy Rittich Avatar answered Aug 18 '26 06:08

D'Arcy Rittich


Use the <%: ... %> style and be sure to remove the semi-colon (;) at the end of the statement.

like image 31
Jonathan Bates Avatar answered Aug 18 '26 06:08

Jonathan Bates



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!