我在VS 2013中有一个Web窗体项目,我在其中通过更新面板中的按钮调用异步进程。我想在异步进程运行时显示等待图标。
我正在使用下面显示的代码隐藏,但是当单击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);
...
}
答案 0 :(得分:0)
您可以使用以下代码更改光标:
Cursor.Current = Cursors.WaitCursor
这应该可以解决您的问题。