I am using mvc in my project, I have done sample registration form with model level validations
In my form I have first name, last name, mobile number and member document details, all are required fields except document details
After Entering the member details I have a button(add document), once I click on it, it will display a textbox, fileupload button i have done this functionality using jquery,after that i will enter the document name in textbox and browse the document using fileupload control, up to here the functionality is working fine.
But after this on post action if any validation occurs in model level for the required fields, the fileupload control is disappearing,so each time again i have to upload the file by clicking the button(add new doc) , is there any alternate to remain the uploaded file on the form?
What I have tried:
My jquery file upload functionality
<table id="doc" class="table table-striped table-hover table-bordered">
<tr>
<th style="width:200px">
Document Name
</th>
<th style="width:500px">
File to Upload
</th>
<th style="width:6px">
</th>
</tr>
@if (Model != null)
{
if (Model.table_dtls_doc != null)
{
for (int i = 0; i < Model.table_dtls_doc .Count; i++)
{
<tr>
<td>
@Html.HiddenFor(model => Model.table_dtls_doc [i].detail_id);
@Html.HiddenFor(model => table_dtls_doc[i].id);
@Html.TextBoxFor(model => model.table_dtls_doc [i].document_name)</td>
<td>
@Html.TextBoxFor(model => model.table_dtls_doc [i].UpFile, new { type = "file" })
<input type="hidden" name="table_dtls_doc .Index" value="@i" />
</td>
</tr>
}
}
}
</table>
<button type="button" name="N" id="N" value="N" class="">Add New Doc </button>