Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
In my form im using update panel inside update panel im using panel.

Inside panel im asp:FileUpload control and a upload button.
When i browse any zip file and click upload button first time .hasfile is becoming false becuase of postback of fileupload control.when i upload second time its becoming true and working correctly.
Pls suggest me why the upload conntrol is postbacking for first time...

additional information copied from comment below
ASP.NET
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
   <contenttemplate>
                    <asp:Panel ID="pnlUpload" runat="server" Font-Names="Verdana" Font-Size="11px" Style="padding: 0px 0px 0px 0px;
                        border: 1px; border-color: #A5C5DE; border-style: solid;" Height="120px" Width="100%">
                        <table style="width: 100%;">
                            <tr>
                                <td>
                                    <div id="dvzip"  runat="server" class="form" style="background-color: #ffffff !important;
                                        width: 100%; vertical-align: top">
                                        <fieldset class="curve_qp">
                                            <legend class="curve_qp">Import ZipFile</legend>
                                            <table id="tblzip"  runat="server">
                                                <tr>
                                                    <td align="right" class="label" style="width: 25%;">
                                                        Password <span class="mandatory_field">*</span>
                                                    </td>
                                                    <td colspan="2" style="width: 75%;">
                                                        <asp:TextBox ID="txtSessionPassword" TextMode="MultiLine" runat="server" CssClass="formContent"
                                                            Width="100%" Height="50px">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label" style="width: 25%;" align="right">
                                                        Choose the FileName to Upload <span class="mandatory_field">*</span>
                                                    </td>
                                                    <td style="width: 55%;">
                                                        <%--<asp:FileUpload ID="filezip" runat="server" CssClass="border" Width="100%" Height="20px"
                                                                BorderWidth="1px" OnInit="filezip_Init" />--%>
                                                        <asp:FileUpload ID="filezip" runat="server" CssClass="border" Width="100%" Height="20px"
                                                            BorderWidth="1px" />
                                                    </td>
                                                    <td style="width: 20%;">
                                                        <asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="formbtn curve_qp label"
                                                            Width="108px" OnClick="btnUpload_Click" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    
                </contenttemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnUpload"  EventName="btnUpload_Click"/>
                    
                </Triggers>
Posted
Updated 9-Dec-13 21:09pm
v2
Comments
jackspero18 10-Dec-13 1:26am    
You Can't use file upload control in Update panel directly..
you must use trigger for that button

In update panel use triggers

ASP.NET
<triggers>
        <asp:postbacktrigger controlid="Uploadbutton" xmlns:asp="#unknown" />

        </triggers>
 
Share this answer
 
v2
Add the asp:postbacktrigger for the UpdatePanel and give the ControlID.
See the code below which will help you.
XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
            <Triggers>
                <asp:PostBackTrigger ControlID="Button1" />
            </Triggers>
            <ContentTemplate>
                <asp:Panel runat="server">
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                    <asp:Button ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" />
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
 
Share this answer
 
v3

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



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