Welcome to AspAdvice Sign in | Join | Help

AzamSharp

Some day I will know everything I hope that day never comes

Syndication

Tags

Navigation

Freeze Page While Processing

In one of my previous postings I explained how you can notify the user that the processing is going on with a simple wait message. If you have not checked that post then click here.

Another way to notifying the user is freezing the whole page so that user cannot press the upload/submit button again.

The freezing work is done by JavaScript. You can check out the complete html code below:

<form id="form1" runat="server">

 

<div id="parentDiv" class="transparent" style="position:absolute; background-color:Gray;

width:100%; height:100%; display:none; top:0px; left:0px; z-index:5000;">

 

</div>

 

<div id="waitIndicatorDiv" class="Indicator" runat="server">

Please wait while the file is being uploaded..

</div>

 

 

<div style="position:absolute; top:100px; left:400px">

 

<h2>File Upload Freeze Screen Demonstration</h2>

 

Select a file: <asp:FileUpload ID="fu1" runat="server" />

 

<asp:Button ID="btn_Upload" Text = "Upload" OnClick="BtnUpload_Click" runat="server" />

 

</div>

 

</form>

</body>

</html>

<script language="javascript" type="text/javascript">

 

 

function FreezePage()

{

document.getElementById("parentDiv").style.display = 'inline';

ShowIndicator();

}

function ShowIndicator()

{

document.getElementById("waitIndicatorDiv").style.display = 'block';

}

 

</script>

If you are interested in using a different indicator image then please visit the following website.

http://www.napyfab.com/ajax-indicators/

And here is the effect.

FreezePage

UPDATE:

.transparent
{
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity:0.5;
}

.Indicator
{
    font-family:Verdana;
    font-size:25px;
    background: Green url(images/indicator_medium.gif) no-repeat right;
    position:absolute;
    top:300px;
    left:500px;
    display:none;
    width: 591px;
    z-index:99999;   
}

Published Sunday, December 10, 2006 11:45 PM by azamsharp

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 RSS

Comments

# re: Freeze Page While Processing @ Monday, December 11, 2006 7:52 PM

The example is missing some tags and has additional spacing that doesn't seem right. Also, shouldn't the effect occur when you actually click the upload button?

Robert

# re: Freeze Page While Processing @ Monday, December 11, 2006 7:59 PM

Hi Robert,

Not sure what tags are missing but yes, you are right the Freeze Page should only be fired when the upload button is clicked. In the code behind you can add the following lines.

Btn_Upload.Attributes.Add("onclick","FreezePage()");

Hope it helps!

azamsharp

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below