<!--use ternary inside razor--> @count=0; <input type="text" class="form-control" @(count == 0?"required":"") >