在此代码中出现问题. [英] Getting problem in this code.

查看:111
本文介绍了在此代码中出现问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button1_Click(object sender, EventArgs e)
        {

int j = 100;
          while (j > 0)
          {
              Thread.Sleep(100);
              label1.Text = Convert.ToString(j);
              j--;
              if (j == 10)
              {
                  j = 100;
              }
          }
}



Asp.net C#窗口应用程序.

在按钮上单击代码将运行..但在运行模式下未以表格形式显示label1的值.
帮助...........

我尝试过的事情:



Asp.net C# window application.

On button click code runs.. but it is not shown the value of label1 in form in running mode.
Help...........

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {

int j = 100;
          while (j > 0)
          {
              Thread.Sleep(100);
              label1.Text = Convert.ToString(j);
              j--;
              if (j == 10)
              {
                  j = 100;
              }
          }
}



Asp.net C#窗口应用程序.

在按钮上单击代码将运行..但在运行模式下未以表格形式显示label1的值.
帮助...........



Asp.net C# window application.

On button click code runs.. but it is not shown the value of label1 in form in running mode.
Help...........

推荐答案

正如Tomas所说,这将永远不会做您认为会做的事. WebForms和WindowsForms是完全不同的技术.

当您在浏览器中键入页面的url时,服务器将完全执行该类,然后将结果html发送到客户端并断开连接.没有固定的连接.

如果您想在页面上执行某种计时器,请查看JavaScript和setTimeout或Google for JavaScript计时器.
As Tomas said this will never do what you think it will do. WebForms and WindowsForms are completely different technologies.

When you type the url of your page into a browser the server executes the class completely and then sends the resultant html to the client and disconnects. There is no constant connection.

If you are wanting to do some sort of timer on a page then look at JavaScript and setTimeout or google for JavaScript timers.


这篇关于在此代码中出现问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆