Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Html Helpers - is Response.Write needed?

When using the Html helpers for ASP.NET MVC I need to wrap them in a Response.Write else they don't appear. However the samples (1&2 for example) I find online for ASP.NET MVC don't seem to do that. Did something change somewhere or am I doing something wrong?

From the samples I find it should be like this:

<div class="row">
  <% Html.ActionLink("View", "Details", "People"); %>
</div>

However that displays nothing, so I need to wrap it in a Response.Write as follows:

<div class="row">
  <% Response.Write(Html.ActionLink("View", "Details", "People")); %>
</div>
like image 639
Robert MacLean Avatar asked Feb 07 '26 04:02

Robert MacLean


1 Answers

You need to write them like this:

<div class="row">
    <%= Html.ActionLink("View", "Details", "People") %>
</div>

Note the <%= before the Html.ActionLink. This writes the value into the response.

like image 133
Praveen Angyan Avatar answered Feb 09 '26 09:02

Praveen Angyan



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!