Javascript 如何在Visual Studio asp.net中将光标更改为等待图标?
我在VS2013中有一个Web表单项目,在该项目中,我从更新面板中的一个按钮调用一个异步进程。我希望在异步进程运行时显示等待图标 我正在使用如下所示的代码隐藏,但是当单击cmdAutoCaption时,光标不会从默认指针更改。但是,在异步过程完成并返回content_字符串后,如果光标移到更新面板之外,它将变为等待图标Javascript 如何在Visual Studio asp.net中将光标更改为等待图标?,javascript,asp.net,Javascript,Asp.net,我在VS2013中有一个Web表单项目,在该项目中,我从更新面板中的一个按钮调用一个异步进程。我希望在异步进程运行时显示等待图标 我正在使用如下所示的代码隐藏,但是当单击cmdAutoCaption时,光标不会从默认指针更改。但是,在异步过程完成并返回content_字符串后,如果光标移到更新面板之外,它将变为等待图标 protected void cmdAutoCaption_Click(object sender, EventArgs e) { 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
这应该能解决你的问题 适用于桌面应用程序,但不适用于网页。没有包含游标和游标对象的System.Windows.Forms程序集。