I have a post where I define a new database entity. After user enters needed values and submits the form, I insert the entity and post it back to the same page and display it's ID. When I enter the ID area disabled
and readonly
as below, it works perfectly.
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
ID:
@Html.TextBoxFor(model => model.ID, new { disabled = "disabled", @readonly = "readonly" })
<p><input type="submit" name="submit" value="Create" /></p>
</fieldset>
}
However, when I enter it only readonly
as in below, it does insert the entity, but doesn't view the ID.
@Html.TextBoxFor(model => model.ID, new { @readonly = "readonly" })
I have another submit in the form, which uses the entities ID. However, I cannot use disabled
here with the ID area, as it doesn't post the ID value. What can I do to resolve the issue?