Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you would implement your own ActionLink extension along the line of:</p> <pre><code>public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, bool noEncode) { var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); var url = urlHelper.Action(actionName, controllerName, routeValues); if (noEncode) url = Uri.UnescapeDataString(url); var tagBuilder = new TagBuilder("a"); tagBuilder.MergeAttribute("href", url); tagBuilder.InnerHtml = linkText; return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal)); } </code></pre> <p>Then you could make your template like:</p> <pre><code>&lt;p class="post-info"&gt; &lt;p class="post-info" data-bind="text UserName"&gt;&lt;/p&gt; &lt;span data-bind="Body"&gt;&lt;/span&gt; &lt;p class="post-footer"&gt; @Html.ActionLink("Comments (${CommentCount})", "IndividualPost", "Post", new {id = "${id}"}, true) &lt;/p&gt; &lt;/p&gt; </code></pre> <p>the serverside html generated would then look like:</p> <pre><code>&lt;p class="post-info"&gt; &lt;p class="post-info" data-bind="text UserName"&gt;&lt;/p&gt; &lt;span data-bind="Body"&gt;&lt;/span&gt; &lt;p class="post-footer"&gt; &lt;a href="/Post/IndividualPost/${id}"&gt;Comments (${CommentCount})&lt;/a&gt; &lt;/p&gt; &lt;/p&gt; </code></pre> <p>which in turn is a perfect template in my opinion.</p> <p>The reason for an ActionLink extension is the fact that the normal Html.ActionLink encodes your url to <code>/Post/IndividualPost/%24%7Bid%7D</code> which doesn't work for the template</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload