如何在Visual Studio asp.net 中将光标更改为等待图标



>我在VS 2013中有一个Web Forms项目,其中我从更新面板中的按钮调用异步进程。我希望在异步进程运行时显示等待图标。

我正在使用如下所示的代码隐藏,但是单击cmdAutoCaption时光标不会从默认指针更改。但是,在异步进程完成并返回content_string后,如果将光标移到更新面板之外,光标将变为等待图标。

 protected void cmdAutoCaption_Click(object sender, EventArgs e)
     {
         string sUser = AuthoriseUser();
         if (sUser == "") return;
         string script1 = "document.body.style.cursor = 'wait';";
         ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script1, true);
         CreateAutoCaption();

     }
     private async void CreateAutoCaption()
     {
         await MakeAnalysisRequestAsync(Session["strImagePath"].ToString());
     }
    private async MakeAnalysisRequestAsync(string imageFilePath)
       {
         ...
      response =  await client.PostAsync(uri, content);
    // Get the JSON response.
      string contentString = await response.Content.ReadAsStringAsync();
        ...
                 string script1 = "document.body.style.cursor = 'auto';";
                 ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script1, true);
         ...
       }

可以使用以下代码更改光标:

Cursor.Current = Cursors.WaitCursor

这应该可以解决您的问题。

最新更新