【问题标题】:how to retain a button1 clicks action with a sleep against another button2 click action without sleep如何保留一个按钮1单击动作与睡眠对抗另一个按钮2单击动作而不睡眠
【发布时间】:2011-07-21 10:55:38
【问题描述】:

我的问题是我在 ASP.Net 的两个不同更新面板中有两个标签和两个按钮。更新面板包含两个按钮。单击按钮时,它将更新相应的标签文本。问题是,假设我在 button1_click() 方法中延迟了 5 秒,当我立即单击 button1 和 button2 时,label2 开始更新,而 label1 没有更新。

你能建议我哪里出错了吗?

protected void Button1_Click2(object sender, EventArgs e)
{
    System.Threading.Thread.Sleep(5000);
    Label1.Text = "Hello";
}

protected void Button2_Click1(object sender, EventArgs e)
{
    Label2.Text = "World";
}

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    在按钮单击事件中,更新显示第二个标签的更新面板,如下所示:

    UpdatePanel2.Update();
    

    【讨论】:

      猜你喜欢
      • 2018-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-13
      • 2018-04-22
      • 2023-03-22
      相关资源
      最近更新 更多