CitySec
asked on
How to make a label disappear after a certain length of time?
I have an asp.net label control which displays messages when users do certain operations on my page. This label control is set to visible="false" until it needs to be displayed, and then programmatically it's visibility is set to "true". When this happens, I don't want it to stay there, I want it to disappear after 5 seconds. What's the best way to do this? Is there an AJAX control that already does this, or do I need some custom Javascript? And if it is Javascript that I need, how do I get the function to fire every time the label's visibility is set to true?
i think you have to use the asp ajax controls to do this...there is a timer that you can use...there...
oops...it's not part of the asp ajax control...It's the UpdateProgress...I'm thinking that if you set it for 5 seconds, then you can cause another event to happen after its finished...say: have an event in you page called makeInvisible(). in the makeInvisible call a <asp:button.....style="dis play:none; "> button which will make label invisible...now, it's important that the label be placed inside of a UpdatePanel and the trigger for that updatePanel be that invisible button...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can hide the label using javascript
add this code after you make label visible in code behind file
ClientScript.RegisterStart upScript(" HideLabel( )",<time in milliseconds>,true);
//add this function to the page
function HideLabel()
{
document.getElementById("L abelID").s tyle = "display:none";
}
(there could be syntax error)
add this code after you make label visible in code behind file
ClientScript.RegisterStart
//add this function to the page
function HideLabel()
{
document.getElementById("L
}
(there could be syntax error)
ASKER
That was the first solution I tried because it was the easiest to paste and required only one line of code. The other solutions may work too, but I didn't try them. One last question, can I make the label fade out instead of disappear at once?