vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, October 3, 2012

How to blink LinkButton or label controls in asp.net?


Here I would like to share the code recently I searched more on Google…it’s a simple process to blink or flash a linkbutton in asp.net using JavaScript.

It’s a small trick to virtually to show linkbutton like blink in asp.net page..
Steps to follow:
1. Initially add linkbutton or label controls on the client side.
2. Call the JavaScript on body onload function.
3. In JavaScript mention the control name to blink.
Code:
<script type="text/javascript">

        function Blink() {

            if (document.getElementById("BlinkMe"))
            //Here you have to mention control name instead of blinkme
            {

                var d = document.getElementById("BlinkMe");
                //Here you have to mention control name instead of blinkme

                d.style.color = (d.style.color == 'maroon' ? 'white' : 'maroon');

                setTimeout('Blink()', 1000);
            }

        }

    </script>

//////////////////////////
</head>
<body onload ="Blink()">
  <asp:LinkButton ID="BlinkMe" runat="server">Reset</asp:LinkButton>
</body>

That’s it now you can run your code …see the magic the linkbutton should blink. Actually in code we just change the link button color to white, but it seems to blink.
Happy coding…………


0 comments:

Post a Comment