Потеря файла в элементе управления загрузкой файлов на панели обновления C# asp.net

У меня есть страница, где я использую 3 панели обновлений, и все панели обновлений работают хорошо. В одной из панелей обновлений у меня есть кнопка, которая при щелчке меняет текст метки, но проблема в том, что при обратной записи в любой из панелей обновлений загрузка файла теряет свой файл. Все панели обновления используются для обновления отдельных разделов страницы. Панель обновлений не является вложенной. загрузка файла не выполняется, т. е. его нет ни на одной из панелей обновления, но он теряет свой файл. Я думаю, что проблема вполне понятна и не нуждается в коде, чтобы показать. Спасибо

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WalkInControl.ascx.cs"
    Inherits="Modules_WalkInControl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>

 <asp:Panel ID="Panel1" runat="server" Font-Size="13px" Width="670">
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers ="true"  UpdateMode="Conditional">
    <ContentTemplate>

            <div class="formfieldset" style="margin-bottom: 40px;">
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Check In :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtCheckIn" runat="server" Width="153px"></asp:TextBox>
                        <asp:ImageButton ID="imgbtnCalendar1" runat="server" ImageUrl="~/App_Themes/Default/images/ico-calendar.gif"
                            CausesValidation="false" Width="20" Height="20" />
                        <ajaxtoolkit:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy"
                            TargetControlID="txtCheckIn" PopupButtonID="imgbtnCalendar1" />
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="[*]"
                            ControlToValidate="txtCheckIn" Display="Dynamic" ValidationGroup="a"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Check Out:
                    </div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtCheckOut" runat="server" Width="153px"></asp:TextBox>
                        <asp:ImageButton ID="imgbtnCalendar" runat="server" ImageUrl="~/App_Themes/Default/images/ico-calendar.gif"
                            CausesValidation="false" ImageAlign="Top" Width="20" Height="20" />
                        <ajaxtoolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
                            TargetControlID="txtCheckOut" PopupButtonID="imgbtnCalendar" />
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:RequiredFieldValidator ID="valStartDate" runat="server" ErrorMessage="[*]" ControlToValidate="txtCheckOut"
                            Display="Dynamic" ValidationGroup="a"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Room Type :
                    </div>
                    <div class="paymentfrmtxtbox">
                        <asp:DropDownList ID="drpRoomtype" runat="server" Width="172px" AutoPostBack="True"
                            OnSelectedIndexChanged="drpRoomtype_SelectedIndexChanged" AppendDataBoundItems="True">
                        </asp:DropDownList>
                    </div>
                </div>
                  <div class="formrow">
                <div class="paymentfrmlabels">
                   Plan :
                </div>
                <div class="paymentfrmtxtbox" style="height: 25px;">

                    <asp:DropDownList ID="drpPlan" Width="172px" AutoPostBack="True"  
                        runat="server" onselectedindexchanged="drpPlan_SelectedIndexChanged1">
                    </asp:DropDownList>
                </div>
            </div>
                <div class="formrow" style="height: 75px;">
                    <div class="paymentfrmlabels">
                        Room :
                    </div>
                    <div class="paymentfrmtxtbox">
                        <asp:ListBox ID="lstRooms" runat="server" Width="172px" SelectionMode="Multiple">
                        </asp:ListBox>
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="lstRooms"
                            ErrorMessage="[*]" ValidationGroup="b"></asp:RequiredFieldValidator>
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                            <ProgressTemplate>
                                <img src="../Images/loading_sm.gif" border="0" alt="">
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="drpRoomtype"
                            ErrorMessage="[*]" ValidationGroup="a"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Adults :
                    </div>
                    <div class="paymentfrmtxtbox" style="width: 50px; height: 25px;">
                        <asp:DropDownList ID="drpAdults" Width="50px" runat="server" AutoPostBack="True"
                            OnSelectedIndexChanged="drpAdults_SelectedIndexChanged" AppendDataBoundItems="True">
                        </asp:DropDownList>
                    </div>
                    <div class="paymentfrmlabels" style="width: 65px;">
                        Children :
                    </div>
                    <div class="paymentfrmtxtbox" style="width: 50px; height: 25px;">
                        <asp:DropDownList ID="drpChildren" Width="50px" runat="server" AutoPostBack="True"
                            OnSelectedIndexChanged="drpChildren_SelectedIndexChanged">
                        </asp:DropDownList>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Rate :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtRate" Width="153px" runat="server"></asp:TextBox>
                    </div>
                    <div class="paymentfrmvalidation">
                        <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtRate"
                            ErrorMessage="Invalid Format" ValidationExpression="^(-)?\d+(\.\d\d)?$" ValidationGroup="a"></asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtRate"
                            ErrorMessage="Rate Required" ValidationGroup="a"></asp:RequiredFieldValidator></div>--%>

                    </div>

                </div> <div align="center"> <asp:Label ID="lblRoomMsg" runat="server" ForeColor="Red"></asp:Label></div>
                 <div class="formrow">
                    <div class="paymentfrmlabels">
                        Advance Pay:
                    </div>
                    <div class="paymentfrmtxtbox" style="height: 25px;">
                        <asp:TextBox ID="txtAdvance" runat="server" Width="153px">0.0</asp:TextBox>
                    </div>
                </div>
                <div class="formrow" style="text-align: right;">
                    <asp:LinkButton ID="lnkAdd" CssClass="btn" runat="server" Width="60px" OnClick="lnkAdd_Click1">ADD</asp:LinkButton>
                </div>


                <div class="formrow" style="text-align:center;">
             <asp:CompareValidator ID="CompareValidator1" runat="server"  ControlToCompare="txtCheckOut"
                ControlToValidate="txtCheckIn" Operator="LessThanEqual" Type="Date" ForeColor="Red"    ErrorMessage="CheckIn Must Be Before CheckOut" 
                Display="Dynamic" ValidationGroup="a"/>

             </div> 
               <div class="formrow" style="height: auto; margin-top: 20px; width: 430px;">
                    <asp:GridView ID="gvAddedRooms" runat="server" CssClass="active-grid" AutoGenerateColumns="False"
                        DataKeyNames="ID" Height="18px" Width="100%" OnRowDeleting="gvAddedRooms_RowDeleting">
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" />
                            <asp:BoundField DataField="RoomTypeX" HeaderText="RoomType" />
                                <asp:BoundField DataField="RoomX" HeaderText="RoomX" />
                            <asp:BoundField DataField="Rate" HeaderText="Rate" DataFormatString="{0:f}" />
                            <asp:BoundField DataField="Adults" HeaderText="Adults" />
                            <asp:BoundField DataField="Children" HeaderText="Children" />
                            <asp:CommandField ShowDeleteButton="True" />
                        </Columns>
                    </asp:GridView>

                </div>
               <div style="float:left;"> <asp:Label ID="Label1" runat="server" Text="Total Charge : " Font-Bold="true" ForeColor ="Blue" style="font-size:19px;"></asp:Label><asp:Label ID="lblTotalAmount" runat="server" Text=""></asp:Label>
                </div>


            </ContentTemplate>
             <Triggers>
             <asp:PostBackTrigger ControlID="gvAddedRooms" />
                                <asp:PostBackTrigger ControlID="drpRoomtype" />
                                <asp:PostBackTrigger ControlID="drpPlan"  />
                                <asp:PostBackTrigger ControlID="lnkAdd"   />
                                <asp:PostBackTrigger ControlID="lstRooms" />
                                   <asp:PostBackTrigger ControlID="drpAdults"   />
                                <asp:PostBackTrigger ControlID="drpChildren" />

                 <asp:PostBackTrigger ControlID="btnRemoveFilename1" />
                            </Triggers>


            </asp:UpdatePanel> 

              <%--<div class="formrow" style="text-align: right;">

             <asp:UpdatePanel ID="UpdatePanel3"  UpdateMode ="Conditional"  runat="server">
                <ContentTemplate >
                      Agency : 
                      <asp:DropDownList ID="drpChannel" runat="server" Width="172px" AutoPostBack="True"
                         Height="32px" >
                    </asp:DropDownList>  
                      </ContentTemplate>
                     <Triggers>
                                 <asp:PostBackTrigger ControlID="drpChannel" 
                                      />
                                <asp:AsyncPostBackTrigger ControlID="lnkNewChannel" EventName="Click" />

                               </Triggers>
                </asp:UpdatePanel>
                       <asp:LinkButton ID="lnkNewChannel" runat="server" >New Channel</asp:LinkButton>
                       </div> --%> 



             <div class="newsubheadingsearchqueryresults" style="width: 685px;">
                <h3>
                    Customer Details</h3>
                <span class="requiredExample">[&nbsp;*&nbsp;] = Required Information</span></div>
            <div class="formfieldset" style="margin-bottom: 40px;">
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Paying Customer :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtCustomerName" Width="153px" runat="server"></asp:TextBox>
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtCustomerName"
                            ErrorMessage="[*]" ValidationExpression="^[a-zA-Z''-'\s]{1,40}$" 
                            ValidationGroup="a" Display="Dynamic"></asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCustomerName"
                            ValidationGroup="a" ErrorMessage="[*]" Display="Dynamic"></asp:RequiredFieldValidator>
                    </div>
                </div>

                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Customer Type :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:DropDownList ID="drpCustomerType" Width="153px" runat="server">
                            <asp:ListItem Text="Person" Value="Person"></asp:ListItem>
                            <asp:ListItem Text="Company" Value="Company"></asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        E-Mail :
                    </div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtEmail" Width="153px" runat="server"></asp:TextBox>
                    </div>
                    <div class="paymentfrmvalidation">
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Phone No :
                    </div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtPhone" runat="server" Height="23px" Width="153px"></asp:TextBox>
                    </div>
                    <div class="paymentfrmvalidation">
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ErrorMessage="Invalid format"
                            Display="Dynamic" ValidationExpression="^[0-9]*$" ControlToValidate="txtPhone"
                            ValidationGroup="a"></asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtPhone"
                            Display="Dynamic" ValidationGroup="a" ErrorMessage="[*]"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="formrow" style="height: 130px;">
                    <div class="paymentfrmlabels">
                        Address:</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtAddress" runat="server" Height="129px" TextMode="MultiLine" Width="153px"></asp:TextBox>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        City :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtCity" runat="server" Width="153px"></asp:TextBox>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        Country :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:DropDownList ID="drpCountry" Width="153px" runat="server">
                        </asp:DropDownList>
                    </div>
                </div>
                <div class="formrow">
                    <div class="paymentfrmlabels">
                        State :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtState" Width="153px" runat="server"></asp:TextBox>
                    </div>
                </div>
                 <div class="formrow">
                    <div class="paymentfrmlabels">
                        Postal Code :</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtPostalCode" Width="153px" runat="server"></asp:TextBox>
                    </div>
                </div>

                <div class="formrow" style="height: 90px; width: 670px;">
                    <div class="paymentfrmlabels">
                        Other Guest Names :</div>
                    <div class="paymentfrmtxtbox" style="margin-right:45px;">
                        <asp:TextBox ID="txtOtherGuest" runat="server" Height="90px" Width="153px" TextMode="MultiLine"></asp:TextBox>
                    </div>
                    <div class="paymentfrmlabels">
                        Other Information:</div>
                    <div class="paymentfrmtxtbox">
                        <asp:TextBox ID="txtOtherInf" runat="server" Height="90px" Width="153px" TextMode="MultiLine"></asp:TextBox>
                    </div>
                </div>



                <div class="formrow" style="vertical-align: text-top;">
                    <div class="paymentfrmlabels">
                        Identity Proof :</div>


                </div>

                <div class="formrow">
                    <div class="paymentfrmtxtbox">
                    </div>
                </div>
                <div class="formrow" style="text-align: right">
                    <div class="paymentfrmlabels">
                      <input id="txtLogoFileName1" type="file" style ="float :left; z-index:999;" name="txtSmallImage1FileName" runat="server" />

                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers ="true"  UpdateMode ="Conditional">
                        <ContentTemplate >
                          <div class="paymentfrmtxtbox">
                       <asp:Button ID="btnRemoveFilename1" runat="server" style="margin-left:50px; float :left; z-index:999;" Text="Remove" OnClick="btnRemoveFilename1_Click">
                        </asp:Button>
                       </div>
                        <asp:Label ID="lblLogoFileName1" runat="server" CssClass="labelText" ForeColor="Silver"> </asp:Label>

                </div>
                 </ContentTemplate>
                         <Triggers >
                         <asp:PostBackTrigger ControlID ="btnRemoveFilename1" />
                         </Triggers>   
                        </asp:UpdatePanel> 
                <div class="formrow" style="width: 300px;">
                   <div class="paymentfrmtxtbox ">
                       <asp:UpdatePanel ID="UpdatePanel3"  UpdateMode ="Conditional"   ChildrenAsTriggers ="true" runat="server">
                <ContentTemplate >
                      Agency: &nbsp;&nbsp;&nbsp;
                      <asp:DropDownList ID="drpChannel" runat="server" Width="153px" AutoPostBack="True"
                         style=" float: right; height: 28px; margin-right: 65px;width: 157px;" >
                    </asp:DropDownList>  
                      </ContentTemplate>
                     <Triggers>
                                 <asp:PostBackTrigger ControlID="drpChannel" 
                                      />
                                <asp:AsyncPostBackTrigger ControlID="lnkNewChannel" EventName="Click" />

                               </Triggers>
                </asp:UpdatePanel>
                       <asp:LinkButton ID="lnkNewChannel" runat="server" style="display:block; float: right;margin-right: -71px; margin-top: 16px;" >New Channel</asp:LinkButton>

                    </div>
                    </div>

                </div>



                <div class="formrow" style="text-align: right; font-weight:bold; color:#000;">

                 </div>








                <div class="formrow" style="text-align: right; width: 670px;">
                    <asp:LinkButton ID="lnkSubmit" CssClass="btn" runat="server" OnClick="lnkSubmit_Click1"
                        Width="65px" ValidationGroup="a">Check In</asp:LinkButton>
                    <asp:LinkButton ID="lnkCheckout" CssClass="btn" Width="65px" runat="server" OnClick="lnkCheckout_Click"
                        ValidationGroup="a">Check Out</asp:LinkButton>
                    <asp:LinkButton ID="lnkCancel" CssClass="btn" Width="65px" runat="server" OnClick="lnkCancel_Click1">Cancel</asp:LinkButton>
                </div>
            </div>
             </div>

            <ajaxtoolkit:ModalPopupExtender ID="ModalPopupExtender1"   BackgroundCssClass="modalBackground" PopupControlID ="pnlChannel" TargetControlID ="lnkNewChannel" CancelControlID ="ImgBtnClose" runat="server">
            </ajaxtoolkit:ModalPopupExtender>


        <asp:Panel ID="pnlChannel" runat="server">
        <div align="right" style ="padding-top :50px" >
           <asp:ImageButton ID="ImgBtnClose" width="25px" Height ="25px" ImageUrl="~/Images/cross.png" runat="server" /></div>
           <div style ="background-color:White ; border :20px; border-color:Blue;padding:20px 40px; border-radius:20px;" >




                <style type="text/css">
    .style1 {
        width: 100%;
    }
    .style2
    {
        text-align: center;
        font-weight: bold;
        font-family: Andalus;
        font-size: xx-large;
        color: #434343;
    }
    .style3
    {
        width: 81px;
    }
</style>
<div>
<table class="style1">
    <tr>
        <td class="style2" colspan="2">
          Agency</td>
    </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
        <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            <asp:Label ID="lblName" runat="server" Text="Name:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtName" runat="server" Width="189px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                ControlToValidate="txtName" Display="Dynamic" ErrorMessage="Mandatory Field!!!" 
                ForeColor="Red" ValidationGroup="acssd23"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" 
                ControlToValidate="txtName" Display="Dynamic" 
                ErrorMessage="Invalid Name Format!!!" Font-Names="Arial" Font-Size="8pt" 
                ForeColor="Red" SetFocusOnError="True" 
                ValidationExpression="^[a-zA-Z-'.\s]{1,50}" ValidationGroup="acssd23"></asp:RegularExpressionValidator>
        </td>
    </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            <asp:Label ID="lblContact" runat="server" Text="Contact:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtContact" runat="server" Width="189px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                ControlToValidate="txtContact" Display="Dynamic" 
                ErrorMessage="Mandatory Field!!!" ForeColor="Red" 
                ValidationGroup="acssd23"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ControlToValidate="txtContact" Display="Dynamic" 
                ErrorMessage="Invalid Contact Format!!!" ForeColor="Red" 
                style="font-size: xx-small" ValidationExpression="^[0-9-+]*$" 
                ValidationGroup="acssd23"></asp:RegularExpressionValidator>
        </td>
    </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            <asp:Label ID="lblAddress" runat="server" Text="Address:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtAddresss" runat="server" Height="64px" TextMode="MultiLine" 
                width="189px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
                ControlToValidate="txtAddresss" Display="Dynamic" 
                ErrorMessage="Mandatory Field!!!" ForeColor="Red" 
                ValidationGroup="acssd23"></asp:RequiredFieldValidator>
        </td>
    </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            <asp:Label ID="lblEmail" runat="server" Text="Email:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtEmails" runat="server" Width="189px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" 
                ControlToValidate="txtEmails" Display="Dynamic" 
                ErrorMessage="Mandatory Field!!!" ForeColor="Red" 
                ValidationGroup="acssd23"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator015" runat="server" 
                ControlToValidate="txtEmail" ErrorMessage="Invalid Email Format!!!" 
                ForeColor="Red" 
                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                ValidationGroup="acssd23"></asp:RegularExpressionValidator>
        </td>
    </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            <asp:Label ID="lblWebsite" runat="server" Text="Website:"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtWebsite" runat="server" Width="189px"></asp:TextBox>
        </td>
    </tr>
          <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
        <td class="style3">
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>

    <tr>
        <td class="style3">
            &nbsp;</td>
        <td align ="right" >
            <asp:Button ID="btnSubmit" CssClass="btn" Width ="140px" runat="server" Text="Submit" 
                onclick="btnSubmit_Click" style="height: 26px" ValidationGroup="acssd23" />
        </td>
    </tr>
</table>
</div>




</div>
        </asp:Panel>
           </asp:Panel>

3 ответа

Решение

Стандартный asp.net элемент управления FileUpload никогда не будет работать с UpdatePanel. Вам нужен специальный элемент управления AsyncFileUpload, как определено в AjaxControl Toolkit.

`<ajaxToolkit:AsyncFileUpload OnClientUploadError="uploadError"
     OnClientUploadComplete="uploadComplete" runat="server"
     ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"
     UploadingBackColor="#CCFFFF" ThrobberID="myThrobber" />`

или вы можете использовать триггеры панели обновления

<Triggers> <asp:PostBackTrigger ControlID="YourControlID" /> </Triggers>

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
            <Triggers>
                <asp:PostBackTrigger ControlID="Button1" />
            </Triggers>
            <ContentTemplate>
                 <asp:FileUpload ID="FileUpload1" runat="server" />
                 <asp:Button ID="Button1" runat="server"Text="Upload" OnClick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

Я потратил весь день на это сегодня, используя любое количество решений, которые я нашел на различных форумах, включая этот, CodeProject.com, форумы asp.net и множество других. Я попытался установить триггеры Postback и триггеры AsyncPostback, и так поздно ночью я не могу вспомнить, что еще. Ни один из них не сработал, включая тот, который отмечен как ответ на этой странице. В конце концов я обнаружил неясный пост 2007 года на форуме asp.net, который по какой-то причине теперь не загружается в мой браузер. Во всяком случае, что, наконец, сработало для меня, это заменить

<form id="form1" runat="server>

пометить с этим:

<form id="Form1" method="post" enctype="multipart/form-data" runat="server">

Работал красиво.

В моем случае это было в файле Site.Master, но в случае публикации на forums.asp.net он работал в файле default.aspx.

Обновление: сайт forums.asp.net не работает, но теперь он снова работает: UpdatePanel + FileUpload + PostBackTrigger не работает.

Другие вопросы по тегам