如何在按钮单击处理期间显示标签?
当我的按钮单击正在处理时,有什么方法可以显示显示“上传..”的标签?
我正在这样做
protected void btnUpload_Click(object sender, EventArgs e)
{
lblOutput.Text="uploading..";
HttpPostedFile postedFile = FileUpload1.PostedFile;
string ClientFileName, ServerFileName;
if ((FileUpload1.HasFile && FileUpload1.PostedFile != null) || txtUrl.Text!="")
{
try
{
HttpPostedFile myFile = FileUpload1.PostedFile;
if (fileType == "Image")
{
if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".png" ||
fileExt == ".bmp" || fileExt == ".tif")
{
ServerFileName = System.IO.Path.Combine(ServerSavePathI, ClientFileName);
string serverPath = Server.MapPath(ServerFileName);
FileUpload1.SaveAs(serverPath);
dbInsert(fileType, fileName, fileExt,
filePath+fileType+"/"+fileName.Replace(" ",string.Empty)+fileExt,
url);
}
}
}
}
}
,但它是在我的文件上传后显示的。
我做错了什么,还是有其他方法可以做到这一点?
Is there any way to show label that shows "uploading.." while my button click is processing?
I am doing it in this way
protected void btnUpload_Click(object sender, EventArgs e)
{
lblOutput.Text="uploading..";
HttpPostedFile postedFile = FileUpload1.PostedFile;
string ClientFileName, ServerFileName;
if ((FileUpload1.HasFile && FileUpload1.PostedFile != null) || txtUrl.Text!="")
{
try
{
HttpPostedFile myFile = FileUpload1.PostedFile;
if (fileType == "Image")
{
if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".png" ||
fileExt == ".bmp" || fileExt == ".tif")
{
ServerFileName = System.IO.Path.Combine(ServerSavePathI, ClientFileName);
string serverPath = Server.MapPath(ServerFileName);
FileUpload1.SaveAs(serverPath);
dbInsert(fileType, fileName, fileExt,
filePath+fileType+"/"+fileName.Replace(" ",string.Empty)+fileExt,
url);
}
}
}
}
}
But it showed after my file has been uploaded already.
Am I doing something wrong, or is there any other way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显示标签文本的优先级低于上传线程。您可以通过使用另一个线程来处理文本更改事件来解决此问题。希望有所帮助。
The priority of showing the lable's text is lower than the upload thread.You can solve this by use another thread to handle the text change event.Hope helps.