2

我有一个页面,我正在使用 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>
4

3 回答 3

4
<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>
于 2013-10-25T11:48:03.160 回答
3

默认的 ASP.NET FileUpload 控件永远不会与 UpdatePanel 一起使用。您需要一个 AjaxControl Toolkit 中定义的特殊 AsyncFileUpload 控件。

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

或者您可以使用 UpdatePanel 触发器

<Triggers>
  <asp:PostBackTrigger ControlID="YourControlID" />
</Triggers>
于 2013-07-30T11:24:25.813 回答
3

今天我花了整个下午,使用了我在各种论坛上找到的任意数量的解决方案,包括这个、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 似乎不起作用

于 2014-11-19T02:21:00.557 回答