Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to Blink a LABEL in Asp.net for every 5 minutes.
=======================================================

Dear Friends,

I have a Label...This label is set as Date on my webform.

It must BLINK for every 5 minutes.....it should blink for just 10 seconds and go.

Please can u show me, how to do this.

Thanks in Advance.
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jun-12 3:10am    
This is quite possible, but -- do yourself a favor, don't do it. What to irritate your users?
--SA

Hi
try this
XML
<body onload="changeColour('flashtext');">

<script type="text/javascript">

function changeColour(elementId) {
    var interval = 1000;
    var colour1 = "#ff0000"
    var colour2 = "#000000";
    if (document.getElementById) {
        var element = document.getElementById(elementId);
        element.style.color = (element.style.color == colour1) ? colour2 : colour1;
        setTimeout("changeColour('" + elementId + "')", interval);
    }
}

</script>

<p id="flashtext">This text will flash!!!</p>


Hope this will Help u
Best Luck
 
Share this answer
 
Comments
Ubaid ur Rahman IT 19-Jun-12 3:06am    
Boss !!

Listen to me, I need like this ??

Design Page
===========
Label -> LabelId - lblmessage

Code behind page
=================
Page_load

lblMessage.Text = "Last Updated at : " + DateTime.Now.AddMinutes(-60).ToLongTimeString();


Just I need to blink the time for every 5 minutes....This label should blink only 10 seconds and go.


Thanks Please help me.
Hi Ubaid,
Reference System.Threading, add an AJAX timer control and a ScriptManager to your aspx page.

XML
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:timer runat="server" ID="tmr1" Interval="300000" ontick="tmr1_Tick"></asp:timer>
    <h1><asp:Label Text="" ID="lblTestTimer" runat="server"></asp:Label></h1>

in timer_tick event put the following codes:
C#
protected void tmr1_Tick(object sender, EventArgs e)
        {
            lblTestTimer.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt");
            lblTestTimer.Visible = true;
            Thread.Sleep(10000);
            lblTestTimer.Visible = false;
            
        }



This will do the trick what you want...Cheers !!

Happy Coding :)
Sunny_K
 
Share this answer
 
v2
Comments
Sunny_Kumar_ 19-Jun-12 4:39am    
Thanks for voting my answer. please don't forget to accept as answer if it helped you achieving the purpose.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900