Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Yes i know it does work with fadein and fadeout if you provide the timer but it does not work with asp.net code behind.</p> </blockquote> <p>There's no difference. ASP.NET controls render as regular html controls. My hunch is that you are not using the proper client ID that's rendered. You have two choices:</p> <ul> <li><p>Add ClientIDMode="static" in your markup as so: </p> <pre><code>&lt;div clientidmode="static" class="success" id="divStatus" runat="server" visible="false" &gt;&lt;/div&gt; </code></pre></li> </ul> <p>And then add the javascript function to automatically hide the div:</p> <pre><code>function autoHide() { //hide after 5 seconds setTimeout(function(){document.getlementById('divStatus').style.display='none';},5000); } </code></pre> <ul> <li><p>simply use <code>&lt;%=divStatus.ClientID%&gt;</code> to get the client id that's ultimately rendered on the page as so: </p> <pre><code>function autoHide() { //hide after 5 seconds setTimeout(function() {document.getlementById('&lt;%=divStatus.ClientID%&gt;').style.display='none';},5000); } </code></pre></li> </ul> <p>From codebehind, you can simply call: </p> <pre><code> ........//more code for deleting Page.ClientScript.RegisterStartupScript(this.GetType(),"somekey","autoHide();",false); </code></pre> <p><strong>UPDATE</strong></p> <p>If you want to even define the <code>autoHide</code> function in code behind, do as follows (note that the last parameter is <code>true</code> in this case, as opposed to <code>false</code> on the previous example):</p> <pre><code> ........//more code for deleting string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='You are done!' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},5000);"; Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true); </code></pre>
 

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