[Last Call] Learn how to a build a cloud-first strategyRegister Now


hide a label on a timer

Posted on 2011-09-14
Medium Priority
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

by:Gurvinder Pal Singh
ID: 36540707
after displaying the message
setTimeout("hideMessage()", 3000);

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

Accepted Solution

Ramkisan Jagtap earned 2000 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="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
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.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

830 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