hide a label on a timer

Posted on 2011-09-14
Last Modified: 2012-05-12
When user clicks submit button I display a message like "Changes saved succefsully". I would like this to be :
1) either gone after 3 seconds
2) when the user clicks on submit again, on client side before post back happens, I want this label to be hidden (so that when the error message shows on a required field validator the success messgae is still not visible from previous click. Please help. Thanks
Question by:TrialUser
LVL 40

Expert Comment

ID: 36540707
after displaying the message
setTimeout("hideMessage()", 3000);

function hideMessage()
   //code to hide the message
LVL 12

Accepted Solution

Ramkisan Jagtap earned 500 total points
ID: 36540834

You can clear that message on event "OnClientClick" of the submit button.
function ClearMessage()
                var btn=document.getElementById('<%=b1.ClientID%>');
                 btn.value=" ";

<asp:Button id="b1" Text="Submit" runat="server" OnClientClick="ClearMessage()" />

LVL 16

Expert Comment

ID: 36543161
see the code below using jquery:

jquery reference:

<script src="" type="text/javascript"></script>
$("#<%= button.ClientID %>").click(function() {
window.setInterval(clear, 3000);

function clear() {
$("#<%= lbl.ClientID %>").text("");

Open in new window


Author Closing Comment

ID: 36545925

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now