I have a couple of forms on the company SharePoint Portal site that take a few seconds to submit. In the back end, they link into our financial packages, and rely on the external application to do some of the processing. As a result, it can take 10 seconds to return the results page. My problem i
s “How do I display a “Processing, please wait message” to the page?
Simple.
1) Set up your message, and style it with css.
<style> #processing{ position:absolute; width:150px; height:100px; top:50%; margin-top:-50px; left:50%; margin-left:-75px; padding:10px; font-weight:700; background-color:blue; color:white; display:none; ) </style>
The important thing in the style definition is “display:none;”. This stops the div from displaying initially.
<div id="processing"> please wait...<br /> <blink>Processing</blink> </div>
2) Add a bit of simple Javascript to the page
<script language="javascript"> function showstatus(){ processing.style.display = 'block'; } </script>
The javascript depends upon your div having an id of “processing”. If you want a different id for your div, please change the line “processing.style.display = ‘block';” accordingly.
nb. In SharePoint WebParts it is a little trickier to do. Add the div in a standard label, and the javascript can be output in the RenderWebPart method using output.Write(blah); It will probably work in the same label as the div, but I used the method above. easy to do, using the Page.RegisterClientScriptBlock() method.
3) Add an “onClick” handler to your button. The easiest way to do it is in the codeBehind.
buttonName.Attributes.Add("onClick","Javascript:showstatus()");
You can add that in your aspx file, if you are using one, but SharePoint WebParts don’t.
4) Build and deploy.
Easy when you know how.