The following Microsoft document will probably be able to help:
Load a file using FileUpload control inside modal popup when using ModalPopupExtender
No file is present when uploading ?
<div class="Modalform" style="display:none;" id="mySidebar">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="w3-bar-item" />
</ContentTemplate> <triggers> <asp:AsyncPostBackTrigger ControlID="BUploadtnMultipleFiles" EventName="Click" /> </triggers> </asp:UpdatePanel>
<asp:Button ID="BUploadtnMultipleFiles" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" />
</div>
<asp:HiddenField ID="HiddenFieldBtnOpen" runat="server" /> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderDiscount" runat="server" BackgroundCssClass="backgroundColor" BehaviorID="mpeD" DropShadow="true" CancelControlID="closeBtn" PopupControlID="mySidebar" TargetControlID="HiddenFieldBtnOpen" />
7 answers
Sort by: Most helpful
-
-
Bruce (SqlWork.com) 68,081 Reputation points
2023-11-13T19:16:44.77+00:00 the update panel does not support the <fileupload> control. you need to use the ajaxToolkit:AsyncFileUpload control
-
QiYou-MSFT 4,326 Reputation points Microsoft Vendor
2023-11-15T07:16:14.89+00:00 Hi @peter liles
I modified your code, and your previous question was: Since your < asp:button > submitted, the page will be refreshed. Then you use asp:updatepanel which is a page refresh control, but you put asp:FileUpload together with asp:button and this doesn't do what you need.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Button ID="HiddenFieldBtnOpen" runat="server" Text="Modal" /> <div class="Modalform" id="mySidebar"> <asp:ScriptManager ID="Script1" runaT="server"></asp:ScriptManager> <asp:FileUpload ID="FileUpload1" runat="server" CssClass="w3-bar-item" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" > <ContentTemplate> <asp:Button ID="BUploadtnMultipleFiles" Text="Upload" runat="server" OnClick ="UploadMultipleFiles" /> </ContentTemplate> <triggers> <asp:AsyncPostBackTrigger ControlID="BUploadtnMultipleFiles" EventName="Click" /> </triggers> </asp:UpdatePanel> </div> <asp:HiddenField ID="HiddenField1" runat="server" /> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="backgroundColor" BehaviorID="mpeD" DropShadow="true" CancelControlID="closeBtn" PopupControlID="mySidebar" TargetControlID="HiddenFieldBtnOpen" /> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderDiscount" runat="server" BackgroundCssClass="backgroundColor" BehaviorID="mpeD" DropShadow="true" CancelControlID="closeBtn" PopupControlID="mySidebar" TargetControlID="HiddenFieldBtnOpen" /> </form> </body> </html>
Best regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
peter liles 556 Reputation points
2023-11-16T15:22:32.5066667+00:00 i had to ignore first modalpopupextender as you have added two in your example illustration? but still i cannot get it to work. the Hasfile property always returns false?
it is a interesting setup compared to own.
i was curious to know how would you go about setup of updatepanel in this scenario where i have fileupload control as previous shown within a modalpopup and a gridview on same page that downloads images from database after they have been saved, during postback.
Actually my page has multiple fileupload controls in series together with textbox controls so that i may enter a description and then display within gridview when fileuploaded during page postback.
-
QiYou-MSFT 4,326 Reputation points Microsoft Vendor
2023-11-17T07:53:48.72+00:00 Hi @peter liles
I will give you an idea: Use iframe tags.
WebForm1.aspx:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="up_attachment" runat="server" Mode="Conditional"> <ContentTemplate> <iframe id="file" name="file" src="File.aspx"></iframe> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
File.aspx:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" /> <asp:TextBox ID="TextBox1" runat="server" Text="Submit"></asp:TextBox> </div> </form> </body> </html>
protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = FileUpload1.HasFile.ToString(); }
OutPut:
Best regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.