Reputation: 21
Is there a way to add white space in MVC while using variables? for example foreach(item in collection) {@item @item}
. How to make a blank space something like " " in it?
Upvotes: 2
Views: 13509
Reputation: 31
In my application I have used a space after the link's name ("Details ") as shown here
@Html.ActionLink("Details ","Details", new { Variable_ID = item.VIP_ID})
@Html.ActionLink("Edit", "Edit", new { Variable_ID = item.VIP_ID })
so my links will look like this: Details Edit, instead of DetailsEdit. You can also put a separation bar like this "Details | ", so you can have Details | Edit
Upvotes: 1
Reputation: 1
If you wish to add single space between item:
foreach(item in collection)
{
<p>@item @item</p>
}
But you will have better flexibility if you wrap it in a HTML element like div or span, and then add padding/margin to the element using CSS.
foreach(item in collection)
{
<div class="user-defined-classname">@item</div>
<div class="user-defined-classname">@item</div>
}
In CSS
.user-defined-classname{
padding-left|right|top|bottom: 10px
}
Suggestion: The "Views" folder is specifically meant to just contain your view files (i.e. .cshtml files).
Try adding your CSS file to a folder in the root of the ASP.NET project. Often, this folder is named "Content", but you can rename it as "Styles" or something else. Then you can load your CSS file from within a view using a link tag:
<link href="~/Content/styles.css" rel="stylesheet" type="text/css" />
Upvotes: 0
Reputation: 3122
//This will work for sure, as MVC C# using razor syntax then you just need to put space between those two only
foreach(var item in collection) {
<span>@item @item</span>
}
Upvotes: 0
Reputation: 274
<span> </span>
Insert "
" to add more blank spaces
Upvotes: 0
Reputation: 48367
You can use pre
tag , which defines preformatted
text.
foreach(item in collection) {
<pre>@item @item</pre>
}
Upvotes: 2
Reputation: 141
have you tried
this can be repeated i.e.
you can do line breaks with <br />
Upvotes: 1