Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I would like know how to make a label blink. I use the following code but doesnt blink.


XML
<asp:Label ID="Label26" runat="server" BackColor="White" Font-Bold="true"
                   Font-Size="Small" ForeColor="Red"
                   style="z-index: 1; left: 185px; top: 155px; position: absolute; text-decoration:blink; width: 135px; height: 19px; font-weight:500;"
                   Text="Please select an option"></asp:Label>


Can anyone guide me?
Posted

Please below code to blink button / label. and this will work with any bowser.

it is tested. you can mail me on mnkumar1976@gmail.com


XML
<script type="text/javascript">
           function enableBlink()
            {
                var aryBlinkingElements = document.getElementsByTagName("BLINK1")
                    for(i=0;i<aryBlinkingElements.length;i++)
                        {
                            objElement = aryBlinkingElements[i];
                            if (objElement.style.visibility == "visible") {
                                objElement.style.visibility = "hidden";
                            }
                            else {
                                objElement.style.visibility = "visible";
                            }
                        }
                    setTimeout('enableBlink()', 1000);
             }
    </script>


<body onload="enableBlink()">

<pre lang="xml">&lt;Blink1&gt; &lt;asp:LinkButton ID=&quot;HelpBtn&quot; runat=&quot;server&quot; Text=&quot;| Monthly Highlight  &quot;
                               CssClass=&quot;txtUserLogin&quot; OnClick=&quot;HelpBtn_Click&quot; CausesValidation=&quot;False&quot;
                               ToolTip=&quot;Click for monthly highlight  &quot; Visible=&quot;true&quot;&gt;&lt;/asp:LinkButton&gt;&lt;/blink1&gt;</pre></body>
 
Share this answer
 
Set the text-decoration property to blink.
Try this:
C#
Label26.Attributes.Add("style", "text-decoration:blink"); //In page_load event.



--Amit
 
Share this answer
 
v2
XML
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<style type="text/css">
.blink
{

text-decoration:blink
}
</style>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:LinkButton ID="lnkButton" runat="server" CssClass="blink">Blinking</asp:LinkButton>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
Hi,
Blinking text using CSS is not supported in all browsers.
http://www.w3schools.com/cssref/playit.asp?filename=playcss_text-decoration&preval=blink[^]

But you can do some tweaking to achive this functionality using JavaScript.

JavaScript
function blinkFont()
{
  document.getElementById("blink1").style.color="red"
  setTimeout("setblinkFont()",1000)
}

function setblinkFont()
{
  document.getElementById("blink1").style.color=""
  setTimeout("blinkFont()",1000)
}


http://www.easywayserver.com/blog/javascript-blink-color-text-font-in-html/[^]
 
Share this answer
 
With a little bit of JavaScript, you can do this quite easily.
Try the solutions at
http://www.dotnetspider.com/forum/126647-blinking-text-ASP.aspx[^]
How to Blink a LABEL in Asp.net for every 5 minutes.[^]
 
Share this answer
 
Comments
Volynsky Alex 3-Apr-14 7:06am    
Nice answer Abhinav S!
Abhinav S 3-Apr-14 7:17am    
Thank you.
Volynsky Alex 3-Apr-14 7:19am    
:-)

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