0

Litteraly i have a problem when put file upload in modal. On this problem, i have a modal bootstrap which have sort of textbox and fileupload as mandatory. When user click save button, then the table or in this case a gridview show name of file and added year while keep the modal is alive and not getting postback or closed.This illustration can be seen here

enter image description here

As long i have tried, i am using update panel to keep the bootstrap alive, but unfortunately, the backdraw is i cannot get any fileupload data. Can anyone tell me how to solve this problem ? or are there any ways to fulfill the condition above, as long as the modal keep alive when user keep save and the gridview is updated? Thank you :)

PS: this is my code

 <asp:ScriptManager runat="server" ID="ScriptManager2" />
.....
     <asp:Panel ID="pnlRegistrationPhase6" runat="server">
         <div class="modal fade " id="registerStep6" role="dialog">
             <div class="modal-dialog modal-lg">
                 <!-- Modal content-->
                 <div class="modal-content">
                     <asp:UpdatePanel runat="server" ID="updRegistrationStep6">
                         <ContentTemplate>
                             <div class="modal-body ac-modal-success p-a0">
                                 <div class="row">
                                     <div class="col-lg-12">
                                         <div class="col-lg-4 col-md-4 p-l0 hidden-sm hidden-xs img-content">
                                             <img src="images/form_registrasi-14-14.jpg" class="img img-responsive btn-block">
                                         </div>
                                         <div class="col-xs-12 pt-15 pb-10 m-b20 hidden-lg hidden-md heading-reg6">
                                             <button type="button" class="close button-close-cust" data-dismiss="modal">X</button>
                                             <h4 class="text-strong m-t5">Certification</h4>
                                             <ul>
                                                 <li>Maximum 3 (three) latest certifications which sorted from the last, required if already have certifications</li>
                                             </ul>
                                         </div>
                                         <div class="col-lg-8 col-md-8 col-lg-offset-4 col-md-offset-4 form-content">
                                             <div class="col-lg-12 p-r m-b10">
                                                 <button type="button" class="close button-close-cust" data-dismiss="modal">X</button>
                                             </div>
                                             <div class="col-lg-12 mt-20">
                                                 <div class="row form-group">
                                                     <div class="col-lg-9 col-lg-offset-3">
                                                         <p class="text-primary text-strong m-b0">Do you have Certification?</p>
                                                         <span>(Internship or Final Paper isn't considered as Certification)</span>
                                                     </div>
                                                 </div>
                                             </div>
                                             <div class="col-lg-12">
                                                 <div class="row form-group">
                                                     <div class="col-lg-9 col-lg-offset-3">
                                                         <div class="radio radio-primary radio-inline">
                                                             <asp:RadioButton runat="server" ID="yescertification" ClientIDMode="Static" OnClick="showStep6();" GroupName="certification" />
                                                             <label for="yescertification">Yes</label>
                                                         </div>
                                                         <div class="radio radio-primary radio-inline">
                                                             <asp:RadioButton runat="server" ID="nocertification" ClientIDMode="Static" OnClick="hideStep6();" GroupName="certification" />
                                                             <label for="nocertification">No</label>
                                                         </div>
                                                     </div>
                                                 </div>
                                             </div>
                                             <div id="step6Content" class="col-lg-12 no-padding hide">
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <label class="col-lg-3 control-label text-strong text-right">Name of Certification<span class="text-danger">*</span></label>
                                                         <div class="col-lg-6">
                                                             <span class="has-float-label">
                                                                 <asp:TextBox runat="server" ID="txtCertificationName" ClientIDMode="Static" placeholder=" " CssClass="form-control form-flat" ValidationGroup="txtCertificationName" />
                                                                 <label class="text-small" for="certname">Certification Name</label>
                                                             </span>
                                                             <span class="text-danger text-small" style="color: #D64541">
                                                                 <asp:RequiredFieldValidator ErrorMessage="Please Insert Certification Name" ControlToValidate="txtCertificationName" runat="server" ValidationGroup="txtCertificationName" />
                                                             </span>
                                                         </div>
                                                     </div>
                                                 </div>
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <label class="col-lg-3 control-label text-strong text-right">Institution/Company<span class="text-danger">*</span></label>
                                                         <div class="col-lg-6">
                                                             <span class="has-float-label">
                                                                 <asp:TextBox runat="server" ID="txtCertificationInstitution" ClientIDMode="Static" placeholder=" " CssClass="form-control form-flat" ValidationGroup="txtCertificationInstitution" />
                                                                 <label class="text-small" for="instname">Institution Name</label>
                                                             </span>
                                                             <span class="text-danger text-small" style="color: #D64541">
                                                                 <asp:RequiredFieldValidator ErrorMessage="Please Insert Certification Institution/Company" ControlToValidate="txtCertificationInstitution" runat="server" ValidationGroup="txtCertificationInstitution" />
                                                             </span>
                                                         </div>
                                                     </div>
                                                 </div>
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <label class="col-lg-3 control-label text-strong text-right">Year of Certification<span class="text-danger">*</span></label>
                                                         <div class="col-lg-2">
                                                             <div class="form-group has-float-label">
                                                                 <asp:DropDownList runat="server" ID="ddlYearCertification" CssClass="form-control form-flat minimal" ValidationGroup="ddlYearCertification" Width="100%" OnChange="removeTextddlYearCertification();" ClientIDMode="Static">
                                                                 </asp:DropDownList>
                                                                 <span class="text-danger text-small" style="color: #D64541">
                                                                     <asp:RequiredFieldValidator ID="rfvddlYearCertification" ErrorMessage="Please Insert Year" ControlToValidate="ddlYearCertification" runat="server" Display="Dynamic" ValidationGroup="ddlYearCertification" InitialValue="0" />
                                                                 </span>
                                                                 <!--<label for="certyear">Combo Box</label>-->
                                                             </div>
                                                         </div>
                                                     </div>
                                                 </div>
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <label class="col-lg-3 control-label text-strong text-right">Upload Certificate</label>
                                                         <div class="col-lg-9">
                                                             <div class="media">
                                                                 <div class="media-left media-middle">
                                                                     <div class="box-upload">
                                                                         <span class="btn btn-primary btn-pill">
                                                                             <asp:FileUpload runat="server" ID="FileUploadCertificate" CssClass="hidden" />
                                                                             <label for="file" class="m-b0">Choose File</label>
                                                                         </span>
                                                                     </div>
                                                                 </div>
                                                                 <div class="media-body media-middle">
                                                                     <span class="text-danger text-small" style="color: #D64541;">There was an error uploading images.
                                                            <br>
                                                                         Please check and try again.</span>
                                                                 </div>
                                                             </div>
                                                         </div>
                                                     </div>
                                                 </div>
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <div class="col-lg-9 col-lg-offset-3">
                                                             <asp:Button Text="Save" runat="server" CssClass="btn btn-primary btn-pill btn-modal-width" ID="btnSaveCertification" CausesValidation="true" OnClick="btnSaveCertification_Click " />
                                                             <asp:Button Text="Clear" runat="server" CssClass="btn btn-primary btn-pill m-l20 btn-modal-width" ID="btnClearCertification" OnClick="btnClearCertification_Click" />
                                                             <%--                                                                        <button class="btn btn-primary btn-pill btn-modal-width">Save</button>
                                                                    <button class="btn btn-primary btn-pill m-l20 btn-modal-width">Clear</button>--%>
                                                         </div>
                                                     </div>
                                                 </div>
                                                 <div class="col-lg-12">
                                                     <div class="row form-group">
                                                         <div class="col-lg-9 col-lg-offset-3">
                                                         </div>
                                                     </div>
                                                 </div>
                                             </div>

                                             <div class="col-lg-12 m-t20">
                                                 <div class="row form-group m-t20">
                                                     <div class="col-lg-8 col-lg-offset-3">
                                                         <button type="button" class="btn btn-primary btn-pill btn-modal-width" data-toggle="modal" data-target="#registerStep5" data-dismiss="modal">Previous</button>
                                                         <button type="button" class="btn btn-default btn-pill m-l20 btn-modal-width" data-toggle="modal" data-target="#registerStep7" data-dismiss="modal">Next</button>
                                                     </div>
                                                 </div>
                                             </div>
                                         </div>
                                     </div>
                                 </div>
                             </div>
                         </ContentTemplate>
                         <Triggers>
                             <asp:AsyncPostBackTrigger ControlID="btnClearCertification" />
                             <asp:AsyncPostBackTrigger ControlID="btnSaveCertification" />
                         </Triggers>
                     </asp:UpdatePanel>
                 </div>
             </div>
         </div>
     </asp:Panel>
Faris Fajar
  • 121
  • 2
  • 12
  • You can use ASP server control button instead of HTML button and add method on click event to get and save the attached file to FileUpload control instead of using trigger, server controls inside the update panel content template block are async by default – Jameel Hussain Sep 28 '17 at 11:13
  • can you give me example on how to do that ? – Faris Fajar Sep 28 '17 at 11:39
  • Do you mean to say that you do not get the attached file in the FileUpload control in the code behind? I think I am not fully understanding your concern, please explain – Jameel Hussain Sep 28 '17 at 12:48
  • yes, because fileupload behavior where need full postback to get the file upload data in code behind or C#. If i use I can get the file. However, the gridview will not loaded and the modal will be closed since the page is refreshed. – Faris Fajar Sep 28 '17 at 15:01
  • You can create a handler, if you are familiar with handlers, use simple html input tag for fileupload and with the help of jquery/javascript, post the chosed file to the handler, save the file in handler, this way you won't even be needing update panel. – Jameel Hussain Sep 29 '17 at 05:54
  • can you show me how to do it? i am not really familiar with handlers – Faris Fajar Oct 01 '17 at 04:42
  • https://stackoverflow.com/questions/18099826/uploading-images-with-asp-net-generic-handler you can check above link, modify it in your own way. you can add handler in your solution, in add item you can find it, and it's extension is .ashx – Jameel Hussain Oct 02 '17 at 04:31

0 Answers0