I have this Create view:
<div class="editor-field">
@Html.TextBoxFor(model => model.First, new { @id = "id1"})
@Html.ValidationMessageFor(model =>model.First)
</div>
and a submit button after the TextBox:
<input type="submit" value="Create" />
part of the Model class looks like this:
public int? First { get; set; }
and this is my web.config:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
So i need to check if value First is already in database before i post this one. If value is already in database add some error.
I understand the part with ModelState.AddModelError but what i cant get arround is this: every time i check for value is null i get result not from the database but it checks if form TextBox is empty or not.
Please help. Thanks in advance.