1

我有一个 asp.net 按钮,formview 插入模板内的文件上传控件,它位于手风琴控件内,它也在更新面板内。但是即使我添加了一个文件,fileupload.hasfile 仍然返回 false。经过一番谷歌搜索后,我了解到 fileupload 不适用于部分回发。我正在尝试将 asp.net 按钮添加为回发的触发器之一,但我不断收到此错误:

A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.InvalidOperationException: A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 
[InvalidOperationException: A control with ID 'lnkBtnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.]
   System.Web.UI.UpdatePanelControlTrigger.FindTargetControl(Boolean searchNamingContainers) +784600
   System.Web.UI.PostBackTrigger.Initialize() +19
   System.Web.UI.UpdatePanelTriggerCollection.Initialize() +82
   System.Web.UI.UpdatePanel.OnLoad(EventArgs e) +230
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

如何获取按钮的 ID,以便将其添加为更新面板的触发器,此外,还有其他方法可以在更新面板中使用 FileUpload 控件吗?

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:Accordion ID="Accordion1" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
        HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
        FadeTransitions="true" SuppressHeaderPostbacks="true" TransitionDuration="250"
        FramesPerSecond="40" RequireOpenedPane="false" AutoSize="Fill" Height="1197px"
        Width="100%">
      <Panes>
        <asp:AccordionPane ID="AccordionPanePlannedRoles" runat="server">
          <Header>
            View ManPower Plan
          </Header>
          <Content>
            <div id="divListView" style="width: 100%; float: left;">
              <asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="pk_PersonelID"
                  DataSourceID="DSRCFormView" Style="margin-left: 0px; background-color: #EFF3FB;"
                  Width="608px" OnItemInserting="FormView1_ItemInserting" OnItemCreated="FormView1_ItemCreated">
                <EditItemTemplate>
                  <div id="titleSpan" class="titleBannerDIV">Edit Personnel</div>
                  <div style="width: 70%; float: left">
                    <table  id="one-column-emphasisB" style="background-color: #EFF3FB;padding: 1px 1px; width:100%">

                      <tr>
                        <td class="style3">
                          Photo:
                        </td>
                        <td colspan="2" style="text-align: left">
                          <asp:FileUpload ID="FileUpload1" runat="server" CssClass="tb10" />
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                      <tr>
                        <td class="style3" colspan="3">
                          <asp:Label ID="lblErr" runat="server" ForeColor="Red" Style="font-weight: 700; text-align: left;"
                              Width="250px"></asp:Label>
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                      <tr>
                        <td class="style3">
                          &nbsp;
                        </td>
                        <td>
                          <asp:LinkButton ID="lnkBtnUpdate" runat="server" OnClick="lnkBtnUpdate_Click" CommandArgument='' <%#Eval("pk_PersonelID") %>'>Update
                          </asp:LinkButton>
                        </td>
                        <td>
                          <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                              Text="Finish" OnClick="UpdateCancelButton_Click" />
                        </td>
                        <td>
                          &nbsp;
                        </td>
                      </tr>
                    </table>
                  </div>



                </EditItemTemplate>

              </asp:FormView>
              <div>
              </div>
            </div>
          </Content>
        </asp:AccordionPane>

      </Panes>
    </asp:Accordion>
  </ContentTemplate>
  <Triggers>

    <asp:PostBackTrigger ControlID="lnkBtnUpdate"  />
  </Triggers>
</asp:UpdatePanel>
4

0 回答 0