How to use update panel on button click asp

此生再无相见时 提交于 2020-01-06 12:50:20

问题


I am creating an .ASP application that will drag and drop image to the stage.

this is my code:

 <asp:UpdatePanel ID="UpdatePanel3" runat="server">
          <ContentTemplate> 
               <asp:Panel ID="stage" runat="server" cssClass="containment-wrapper" style="border:1px solid #000000;" data-ajax="false">
                        <asp:Image ID="imgBrowse" runat="server" Height="376px" Width="640px" ImageUrl="Image/IC_BPO_ConnectedBPOClick-Startup_v1.1.png" CssClass="zClass" style="cursor:pointer"/>
               </asp:Panel>
          </ContentTemplate>
  </asp:UpdatePanel>
  <asp:Button ID="btnSaveImage" runat="server" Text="Button" OnClick="btnSaveImage_Click" />

Is it possible not to refresh the stage panel after clicking the btnSaveImage?


回答1:


You can set the UpdateMode of the UpdatePanel to Conditional

<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
      <ContentTemplate> 
           <asp:Panel ID="stage" runat="server" cssClass="containment-wrapper" style="border:1px solid #000000;" data-ajax="false">
                    <asp:Image ID="imgBrowse" runat="server" Height="376px" Width="640px" ImageUrl="Image/IC_BPO_ConnectedBPOClick-Startup_v1.1.png" CssClass="zClass" style="cursor:pointer"/>
           </asp:Panel>
      </ContentTemplate>
  </asp:UpdatePanel>

To update the UpdatePanel, you can update it via one of the following ways:

  1. If the Update method of the UpdatePanel control is called explicitly.
  2. If a control is defined as a trigger by using the Triggers property of the UpdatePanel control and causes a postback. In this scenario, the control is an explicit trigger for updating the panel content. The trigger control can be either inside or outside the UpdatePanel control that defines the trigger.
  3. If the ChildrenAsTriggers property is set to true and a child control of the UpdatePanel control causes a postback. In this scenario, child controls of the UpdatePanel control are implicit triggers for updating the panel. Child controls of nested UpdatePanel controls do not cause the outer UpdatePanel control to be updated unless they are explicitly defined as triggers.



回答2:


You can try this...

<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
   <ContentTemplate> 
        <asp:Panel ID="stage" runat="server" cssClass="containment-wrapper"          style="border:1px solid #000000;" data-ajax="false">
                    <asp:Image ID="imgBrowse" runat="server" Height="376px" Width="640px" ImageUrl="Image/IC_B`enter code here`PO_ConnectedBPOClick-Startup_v1.1.png" CssClass="zClass" style="cursor:pointer"/>
           </asp:Panel>
      </ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveImage" EventName="click"/>
</Triggers>
</asp:UpdatePanel>

Please feel free to mark as answer if the answer satisfies you....



来源:https://stackoverflow.com/questions/22476535/how-to-use-update-panel-on-button-click-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!