[英]ASP.NET refresh part of web page while other web-service returns its call
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
<asp:Timer ID="Timer1" runat="server" Interval="1000"
OnTick="StatusTimer_Tick" Enabled="False" />
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1"/>
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="Label2"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" Event="Click"/>
</Triggers>
</asp:UpdatePanel>
protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "Refreshed at : " + DateTime.Now.ToLongTimeString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Timer1.Enabled = true;
//Call some web-service
XMLComparisonService.Service1SoapClient oService = new XMLComparisonService.Service1SoapClient();
oService.XMLComparison();
}
Button1_Click
啟用Timer1
。UpdatePanel1
中的Label1
應該每 1 秒刷新一次! (使用Label1
打印當前時間)Button1_Click
還調用 Web 服務方法“XMLComparison” 但是在調用 Web 服務方法“XMLComparison”后, Label1
不會刷新......我的方法有什么問題嗎?
問候-帕拉格
看起來您正在調用 Web 服務,但在更新頁面之前沒有等待響應。
這是一個例子
http://www.codeproject.com/KB/webservices/WebServiceConsumer.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.