How to add a second css class with a conditional value in razor MVC 4

Your answer (assuming this works, I haven’t tried this):

<div class="details @(@Model.Details.Count > 0 ? "show" : "hide")">

Second option:

@if (Model.Details.Count > 0) {
    <div class="details show">
}
else {
    <div class="details hide">
}

Third option:

<div class="@("details " + (Model.Details.Count>0 ? "show" : "hide"))">


https://stackoverflow.com/questions/15700741/how-to-add-a-second-css-class-with-a-conditional-value-in-razor-mvc-4
https://stackoverflow.com/questions/37836496/razor-add-class-if-condition-is-false

Binding arrays in ASP.NET MVC without index?

You don’t need to explicitly index flat data. If in your view you have

<input type='text' name='data' value='George' />
<input type='text' name='data' value='John' />
<input type='text' name='data' value='Paul' />
<input type='text' name='data' value='Ringo' />

Then in your controller you can use

public ActionResult Create(string[] data)
{
    //data should now be a string array of 4 elements
    return RedirectToAction("Index");
}

Source: https://stackoverflow.com/questions/21616052/binding-arrays-in-asp-net-mvc-without-index/21616554

url.action with query string in razor view

<script type="text/javascript">
   var src = "@Html.Raw(Url.Action("GetProductImage", new { productId = Model.Product.Id, pos = 1, size = 0 }))";
   $(document.createElement("img")).attr("src", src);
</script>


https://stackoverflow.com/questions/5872157/mvc3-url-action-querystring-generation