1.调用__doPostBack使UpdatePanel刷新。

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
<asp:UpdatePanel runat="server" ID="UpdatePanel1" OnLoad="UpdatePanel1_Load"> <ContentTemplate> <asp:Label runat="server" ID="Label1" /> </ContentTemplate> </asp:UpdatePanel>
</div>

2.触发按钮的click()事件(这样触发click可能在firefox中不起作用,但在ff用jquery来触发似乎就可以)

<asp:Button ID="button" runat="server"
                    OnClick="button_Click" style="display:none;"/>

<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
  <ContentTemplate>
    <asp:Label ID="label" runat="server"></asp:Label>
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="button" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

3.来自老赵的杰作,编写一个组件JavaScriptUpdater。

 

前两种方法都是硬编码的意思,老赵的方法可以说更“微软”化。

链接:编写组件,使用JavaScript更新UpdatePanel

 
<script type="text/javascript">
function refreshPanelUpdate()
{
   var obj = document.getElementById("<%= button.ClientID %>");
   obj.click();
}
</script>

相关文章:

  • 2021-09-06
  • 2021-07-08
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-05-30
  • 2022-02-24
  • 2022-02-17
  • 2022-12-23
  • 2021-06-30
  • 2021-06-25
相关资源
相似解决方案