【问题标题】:ASP.NET refresh part of web page while other web-service returns its callASP.NET 刷新网页的一部分,而其他 Web 服务返回其调用
【发布时间】:2011-08-16 21:22:02
【问题描述】:

WebPage.aspx

<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>

WebPage.aspx.cs

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();
}
  1. 所以Button1_Click 启用Timer1
  2. Label1 中的 UpdatePanel1 应该每 1 秒刷新一次! (Label1 打印当前时间)
  3. Button1_Click 也调用网络服务方法“XMLComparison”

Label1 在调用 Web 服务方法“XMLComparison”后不会刷新... 我的方法有什么问题吗?

问候 -段落

【问题讨论】:

    标签: asp.net asp.net-ajax


    【解决方案1】:

    看起来您正在调用网络服务,但在更新页面之前没有等待响应。

    这是一个例子

    http://www.codeproject.com/KB/webservices/WebServiceConsumer.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      • 2012-05-28
      • 2023-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多