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"))">

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");


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);