I am passing a variable ViewBag.crimeRef from my controller and am using it to display a message which works fine:
@if(ViewBag.crimeRef != null)
{
<div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Sorry, there are no matching results for the crime reference <strong>@ViewBag.crimeRef</strong>. Please try searching again.
</div>
}
I figured I could use the same methodology to populate the input's value too, however I'm getting a CS1002: ; expected
error:
<input type="text" class="form-control" maxlength="11" id="crimeRef" name="crimeRef" placeholder="Crime reference"
@if(ViewBag.crimeRef != null) { value="@ViewBag.crimeRef" }>
Is there anyway I can populate the input's value using the ViewBag variable?
Many thanks