Note that there are some explanatory texts on larger screens.

plurals
  1. POImage is not appearing when Showing a Div with loading image during Postbacks ASP.net
    primarykey
    data
    text
    <p>I am intending to show a Div with loading image during page post-backs to inform the user about a runing operation. I am using a simple javascript function that shows the div, when I call this JavaScript from an html input button (without postback), the div is appearing normally. But when I use it with a post-back button, (by setting its OnClientClick property), the div is appearing, but without the image unloaded (showing as a box with unloaded image). I am not able to figure where the problem is, I even tried adding the image as a hidden html control so that it is preloaded before the post-back, but with no prevail. Here is my aspx code:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript" language="javascript"&gt; function PleaseWait(message) { message = message ? message : PleaseWaitDefaultMessage; var dsoctop = document.all ? window.document.body.scrollTop : window.pageYOffset; var el = document.getElementById("PleaseWaitDiv"); el.style.top = (dsoctop + 100) + "px"; el.style.left = "0px"; el.innerHTML = "&lt;div style='background-color:white;border: solid 0px black; width:100%;'&gt;&lt;img src='" + WebSiteBaseURL + "Images/bigrotation2.gif' /&gt;&lt;h3&gt;" + message + "&lt;/h3&gt;&lt;/div&gt;"; el.style.display = ""; } &lt;/script&gt; &lt;asp:Literal ID="InitLiteral" runat="server" EnableViewState="false"&gt;&lt;script&gt;var PleaseWaitDefaultMessage = "{0}"; var WebSiteBaseURL = "{1}"; &lt;/script&gt; &lt;/asp:Literal&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;div id="PleaseWaitDiv" style="width: 100%; position: absolute; top: 0px; display: none; text-align: center; z-index: 2; max-width: 1024px; min-width: 600px; height: 260px; overflow: hidden; background: #fff; margin: 0 auto; left: 0; right: 0;"&gt; &lt;/div&gt; &lt;asp:Button ID="btnTestPleaseWait" runat="server" OnClientClick="PleaseWait();" Text="Test Please wait with postback" onclick="btnTestPleaseWait_Click" /&gt; &lt;input type="button" onclick="PleaseWait();" value="Test Please wait no postback" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and here is my code behind:</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { InitLiteral.Text = string.Format(InitLiteral.Text, "Please Wait.....", Page.ResolveClientUrl("~/")); } protected void btnTestPleaseWait_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload