Creating a Wait Message
This little trick I learned while browsing and reading the www.asp.net forums. The trick is about creating the "Wait Message". Suppose, you are uploading a large file or doing any operation which takes long time to complete. Then it is a better idea to let the user know that something is going on. The wait message should appear when the request is being processed and should dissappear when the request has been completed.
Check out the following code:
<div>
Select a file: <asp:FileUpload ID="fu1" runat="server" />
<br />
<br />
<asp:Button ID="Btn_Upload" onmouseup="ShowWaitBox()" runat="server" Text="Upload" OnClick="Btn_Upload_Click" />
<div id="waitBox" class="waitBoxStyle">
Please wait while the file is being uploaded...
</div>
</div>
<
script language="javascript" type="text/javascript"> function
ShowWaitBox() {
document.getElementById("waitBox").style.display = 'block';
}
</
script> And here is the CSS file:
.waitBoxStyle
{
background:#FFFF66 url(images/waitIndicator.gif) no-repeat right top;
position:absolute;
top:400px;
left:300px;
right:550px;
font-family:Verdana;
display:none;
}
The heart of this code snippet is the onmouseup event which is fired when the mouse button is up. It will make the div visible and as soon as the page is loaded the div will be invisible again.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using