0

I have two forms in my view: One of them is modal and could get excel file. after importing excel file and proccessing its data -> i need these data in the other form of my view. How Can I Handle this?

i want when i submit excel import form, its data show in the first form for sending sms.

Here is my view code

<form asp-controller="Festival" asp-action="SendNotificationToCustomer" method="post">
   <div class="card-body">
      @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.FestivalDetailsTop, additionalData = Model })
      <div class="card card-default">
         <div class="card-body">
            <div class="form-group row" id="OperatorName-area">
               <div class="col-md-12">
                  <div class="input-group">
                     <div class="col-md-6">
                        <div class="input-group">
                           <nop-select asp-for="SelectedCustomerRoleIdsForSms" asp-items="Model.AvailableCustomerRolesForSms" asp-multiple="true" />                          
                        </div>
                        <label asp-for="SMSPhonenumbers" />
                        <textarea asp-for="SMSPhonenumbers" asp-required="true" />
                        <span asp-validation-for="SMSPhonenumbers"></span>
                     </div>
                     <div class="col-md-6">
                        @Html.HiddenFor(x=>x.Id)
                        <label asp-for="TextMessage" />
                        <textarea asp-for="TextMessage" asp-required="true" />
                        <span asp-validation-for="TextMessage"></span>
                     </div>
                     <div class="input-group-append py-2">
                        <button type="submit" id="btnSendNotification" class="btn btn-info rounded-sm">
                        @T("Admin.festival.notification.Button")
                        </button>
                     </div>
                     <div class="input-group-append py-2 mr-2">
                        <button type="button" name="importexcel" class="btn bg-olive rounded-sm" data-toggle="modal" data-target="#importexcel-window">
                        <i class="fas fa-upload"></i>
                        @T("Admin.Common.Import")
                        </button>
                     </div>
                     <span>@Model.PhonenumbersFromExcel</span>
                  </div>
                  <span asp-validation-for="TextMessage"></span>
               </div>
            </div>
         </div>
      </div>
   </div>
</form>
<div id="importexcel-window" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="importexcel-window-title">
   <div class="modal-dialog">
         <form asp-controller="Festival" asp-action="ImportPhonenumbersFromExcel" method="post"         enctype="multipart/form-data">
            <div class="form-horizontal">
               <div class="modal-body">
                  <div class="form-group row">
                     <div class="col-md-2">
                        <div class="label-wrapper">
                        </div>
                     </div>
                     <div class="col-md-10">
                        <input type="file" id="importexcelfile" name="importexcelfile" class="form-control" />
                        <input type="hidden" id="currentId" name="currentId" value="@Model.Id" />
                     </div>
                  </div>
               </div>
               <div class="modal-footer">
                  <button type="submit" class="btn btn-primary"></button>
               </div>
            </div>
         </form>
      </div>
   </div>
</div>
Aref_Za
  • 15
  • 2
  • you can use two pages for this, or just one... (standard post/redirect or AJAX call with JS updating the DOM on callback.) Either way you need to create a class to store the data and bind that to the new form (or have JS handle it and update accordingly) If using two pages, you'd probably want to store the information in a database and then retrieve on the redirect page's controller. – pcalkins Jan 16 '23 at 19:49
  • Apache POI is good for processing the files. Remember, though that Excel files can contain a very large amount of data, so you may be sending back a very large JSON object in your callback. This may require changing ASP.NET's default parameter size limits. – pcalkins Jan 16 '23 at 19:58
  • Where do you proccess its data ? – Qing Guo Jan 17 '23 at 02:58
  • ya know, I didn't think about it before, but I guess you could process the file client-side... there will be a size limitation, but if you are trying to process via Javascript you might check this thread: https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5 – pcalkins Jan 17 '23 at 20:28

0 Answers0