I have created a web page using MVC Razor. On this page, I included a div element with the following structure:
<div class="row" id="DivDisableForView">
<div class="col-md-4">
<label for="" class="control-label">
Product
</label>
<br />
@Html.DropDownListFor(m => m.ProductSeq, Model.products.ToSelectListItems(x => x.ProductName, x => x.Id.ToString(), "", true, "", "Select"), new { @class = "form-control" }).DisableIf(() => Model.IsReadOnly == true || !Model.IsAdd)
@Html.HiddenFor(m => m.ProductSeq)
</div>
<div class="col-md-4" runat="server">
<b>Exception Type</b>
<br />
@Html.EnumRadioButtonFor(m => m.enumExceptionType, true).DisableIf(() => Model.IsReadOnly == true || !Model.IsAdd)
@Html.HiddenFor(m => m.enumExceptionType)
</div>
<div class="col-md-4" id="divTranMode">
<b>Transaction Mode</b>
<br />
@Html.EnumRadioButtonFor(m => m.enumTransactionMode, true).DisableIf(() => Model.IsReadOnly == true || !Model.IsAdd)
@Html.HiddenFor(m => m.enumTransactionMode)
</div>
</div>
if (Model.IsAdd)
{
<div class="row" id="ViewButton">
<button id="btnView" name="Submit" class="btn btn-default">
View
</button>
</div>
}
...
...
...
When the view button is clicked, a grid populates based on the data from the fields above and those fields are disabled as shown below:
$("#DivDisableForView").prop('disabled', true);
However, when submitting the form, the data from the disabled fields becomes null. How can I prevent this or disable a div without clearing its value? Any assistance would be greatly appreciated.