Check if Html.ValidationSummary() has a value

To use with razor syntax

@if (!Html.ViewData.ModelState.IsValid)
{
    // show error
}

or you can wrap it up as an extension method

public static bool HasErrors(this HtmlHelper helper)
{
    return helper.ViewData.ModelState.IsValid == false;
}

Use it as

@if (Html.HasError())
{
    // show error
}

<%if (!Html.ViewData.ModelState.IsValid){%>

If you need to check for errors not related to any specific fields, you could try this:

@if(Html.ViewData.ModelState.ContainsKey(string.Empty))
{
    <div class="panel panel-danger">
        <div class="panel-heading">
            @Html.ValidationSummary(true)
        </div>
    </div>
}