Hi, all
I got a question.
I have a FileUpload component outside a UpdatePanel Control, and a Button named "Upload" inside a UpdatePanel.
When I clicked Upload, and get the FileName property of FileUpload1, it contains nothing. And the HasFile property is False.
What's wrong with it? And how to handle it?
thanks.
File uploads do not work inside of updatepanels. The button you are clicking is causing a postback, but it has nothing to do with the upload file control textbox and what the path is to the file.
To get ajax style behavior from the file upload consider using the iframe technique.
http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/
Good Luck,
Louis
FileUpload controls will work with UpdatePanels, but you must set the button as a PostBackTrigger instead of an AsynchPostBackTrigger.
------------------
When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.
thanks
I have already tried to set a PostBackTrigger instead of AsyncPostBackTrigger, but it still not work.
<asp:UpdatePanel ID="upFile" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="File1" runat="server" Style="display: none" onpropertychange="ctl00_cphMain_txtFile.value = this.value" />
<asp:Button ID="btnUpload" runat="server" Text = "upload" OnClick="btnUpload_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:TextBox ID="txtFile" runat="server" ReadOnly="true" />
<asp:Button ID="btnFile" runat="server" Text="Browse" OnClientClick="javascript:document.getElementById('ctl00_cphMain_File1').click(); return false;" />
ps: I uses a MasterPage, any questions with it?
FileUpload controls is not compatible with UpdatePanel when they are used to upload files as part of an asynchronous postback
See this
http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx
It seems that I can't get FileUpload and UpdatePanel work together..
thanks all
No comments:
Post a Comment