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+"/"+fileN开发者_运维百科ame.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?
<script type="text/javascript">
function showMessage() {
document.getElementById("<%= lblOutput.ClientID %>").innerHTML = "uploading..";
}
</script>
<asp:FileUpload runat="server" ID="FileUpload1" />
<asp:Button runat="server" ID="btnUpload" Text="Upload" OnClick="btnUpload_Click" OnClientClick="showMessage()" />
<asp:Label runat="server" ID="lblOutput" />
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.
精彩评论