为什么在更新面板中按回发

时间:2014-05-05 13:57:23

标签: c# asp.net triggers updatepanel postback

我在更新面板中有asp.net按钮控件。我不希望它发回来,但它的回帖请告诉我为什么回帖

<form id="Form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server">
     </asp:ScriptManager>
     <asp:FileUpload ID="fuVideo" runat="server" />
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
              <asp:Button ID="btnUploadVideo" UseSubmitBehavior="false" Text="Use selected image" OnClick="btnUploadVideo_Click" CssClass="button close_button hi" runat="server" ClientIDMode="Static" />
         </ContentTemplate>
     <Triggers>
           <asp:PostBackTrigger ControlID="btnUploadVideo" />
     </Triggers>
     </asp:UpdatePanel>
</form>

1 个答案:

答案 0 :(得分:0)

您可以覆盖更新面板内的整个控件并设置触发器..

<form id="Form1" runat="server">
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
      <asp:FileUpload ID="fuVideo" runat="server" />

              <asp:Button ID="btnUploadVideo" UseSubmitBehavior="false" Text="Use selected image" OnClick="btnUploadVideo_Click" CssClass="button close_button hi" runat="server" ClientIDMode="Static" />
   </ContentTemplate>
   <Triggers>
           <asp:AsyncPostBackTrigger ControlID="btnUploadVideo" />
   </Triggers>
   </asp:UpdatePanel>
</form>

注意: - 使用AsyncPostBackTrigger而非PostBackTrigger ...