Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i want to upload a picture using file upload control.i am using update panel.when i am submitting the form,fileupload.hasfile returns false.how do i solve this?
Posted

just add the following code into your application.
that will cuse the panel to postback and eventually the fileupload control will start working.
XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
 <Triggers>
  <asp:PostBackTrigger ControlID="Button1" />
 </Triggers>
 
Share this answer
 
v2
Comments
miteshjain1 23-Jan-14 7:36am    
as if i dont want to make page reload or refresh than what shall i have to do
Place the button into separate UpdatePanel and set the PostBack trigger there
Ex:
XML
<asp:updatepanel id=""up1"" runat=""server"><br" mode="hold" xmlns:asp="#unknown" /><ContentTemplate>
 <table><tr> <td>
<asp:Button ID="btnSubmit" runat="server" CssClass="tbutton" OnClick="btnSubmit_Click"Text="Submit" ToolTip="Click here to Submit"                   ValidationGroup="Save" /> </td >

XML
</tr>
 </table>
 </ContentTemplate>
 <Triggers>
 <asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
 </asp:UpdatePanel>
 
Share this answer
 
v2
try this -

C#
Page.Form.Attributes.Add("enctype", "multipart/form-data");
 
Share this answer
 
v2
Add this
HTML
Page.Form.Attributes.Add("enctype", "multipart/form-data");

it will start working.

Also set the update mode of the update panel to conditional. and add a trigger and set it's controlId to the upload button
 
Share this answer
 
v2
Works for me! thanks :-)

Page.Form.Attributes.Add("enctype", "multipart/form-data");



My problem is :

Have used Fileupload control in update panel. failed to load file.
added this in Page load event and added a trigger (postbacktrigger) in update panel. Now Works perfectly.
 
Share this answer
 
i also face same problem. i used postback trigger.

XML
<asp:updatepanel id="updPnl"  runat="server" UpdateMode="conditional">
<ContentTemplate>
</ContentTemplate>
<Triggers>
  <asp:PostBackTrigger ControlID="Button1" />
 </Triggers>
 
Share this answer
 
Page.Form.Attributes.Add("enctype", "multipart/form-data");

You Refer This link
http://blog.anofsinger.com/2007/10/file-upload-not-working-on-first.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900