leora
leora

Reputation: 196449

whitespace in asp.net mvc views

i have the following code in the asp.net mvc view

if (isLoggedInUserAdmin)
{%>
     <%=Html.ActionLink("View", "Details", new {id = item.Mail_ID})%>,
     <a href='/Users/ConfirmDelete?id= <%=item.Mail_ID%>' class="delete">Delete</a>
<%}
if (userRequiresApproval)
{%>
      ,<%= Html.ActionLink("Approve", "Approve", new { id = item.Mail_ID })%>
<%}%>

The issue is that it shows up as:

View, Delete , Approve

instead of

View, Delete, Approve

Does anyone know why there would be a space between Delete and the next "," ??

Upvotes: 2

Views: 344

Answers (2)

womp
womp

Reputation: 116977

There's a newline and a bunch of whitespace between your link and your comma. You'll need to strip it all out if you don't want any space there.

Upvotes: 0

Timothy S. Van Haren
Timothy S. Van Haren

Reputation: 8966

More than likely it's from between the {%> on the one line and the , on the next line.

I would forgo the nice indentation and deal with having tag soup by getting <%} if (userRequiresApproval) {%>,<%=... onto a single line. Do this as much as possible until the space goes away.

You may also need to get the Delete anchor on the same line as the if (userRequiresApproval) statement, as well.

Upvotes: 2

Related Questions