Blinking text

Hi,

I searched online that found this can create blinking text

         function blink_text() {
             $('.blink').fadeOut(500);
             $('.blink').fadeIn(500);
         }
         setInterval(blink_text, 2000);

 <li><a href=mypage.aspx" class="iframe"><span class="blink">To Do List</span></a></li>

Open in new window


My question is, is there a way to incorporate this into code behind. So when sql returns more than one record, the text will blink. thanks
mcrmgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Snarf0001Commented:
Well first I would have to warn that if you have blinking text, there's a good probability you're going to really annoy your users.
But with that being said, you should look at doing this with animations and a simple class name instead of javascript.
It will perform far better, and be easier to maintain and add from code as you're asking for:

Html:
<span class="blinking">Flashing Text</span>

Open in new window


CSS:
.blinking { animation: blinking 2s ease-in-out infinite;  }

@keyframes blinking {
  0% { opacity: 1; }
  25% { opacity: 0; }
  50% { opacity: 1; }
}

Open in new window

0
mcrmgAuthor Commented:
Thanks for the quick reply. The idea is to blink only where they have items on their list.

Is there a way to call the blinking class from code behind based on the condition? thanks
0
Snarf0001Commented:
Yes, I would just conditionally add the class to the target element based upon your condition.  IE only add "blinking" if xxx = true.
If you want to post some of the code where you're rendering / loading the elements, can have a look.
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

mcrmgAuthor Commented:
please have a look

    private void LoadTest()
    {

        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());

        try
        {
            con.Open();
            SqlCommand SqlCom = con.CreateCommand();
            SqlCom.CommandText = "Execute st_test @user";

            SqlCom.Parameters.Add("@user", System.Data.SqlDbType.varchar.20).Value =  user.text;
 



            SqlDataReader reader = SqlCom.ExecuteReader();

            if (reader.Read())
            {
				***blink here
            }

            con.Close();

        }
        catch (Exception ex)
        {

            lblmessage.Text = ex.Message;

            con.Close();
        }


    }

Open in new window

0
Snarf0001Commented:
Sorry, should have specified.  Need the front end code where you're binding and spitting out the HTML as well.
I just don't get the full picture at the moment.  What text is actually blinking?  Is this part of a label?  In a grid?
You mentioned multiple elements being targeted, so really need to understand the context of what you're doing to provide help.

Full code, or link to a page where we can see it or something like that.
0
mcrmgAuthor Commented:
<li><a href="ContactManagementToDoList.aspx" class="iframe"><span class="blink">To Do List</span></a></li>

Open in new window



This is the code form HTML. It is just one link will blink. So when a user logs in, it will check if they have any open items. If they do, the "To Do List" will blink. They will have to click on "To Do List" to see the details. (this part is done).

However, if they do not have any open item, "To Do List" will stay solid.  thanks
0
Snarf0001Commented:
Okay, so if you're not using server controls, you could still set a page level variable in the code behind, and then conditionally add the class to the span:

    public bool HasTasks { get; set; }

    private void LoadTest()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());

        try
        {
            con.Open();
            SqlCommand SqlCom = con.CreateCommand();
            SqlCom.CommandText = "Execute st_test @user";
            SqlCom.Parameters.Add("@user", System.Data.SqlDbType.varchar.20).Value =  user.text;
            SqlDataReader reader = SqlCom.ExecuteReader();

            if (reader.Read())
            {
				***blink here
				HasTasks = true;
            }

            con.Close();
        }
        catch (Exception ex)
        {

            lblmessage.Text = ex.Message;

            con.Close();
        }


    }

Open in new window

And then on the front end:
<li><a href="ContactManagementToDoList.aspx" class="iframe"><span class="<%= HasTasks ? "blink" : string.Empty %>">To Do List</span></a></li>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Snarf0001Commented:
If you are using server controls, it would be easier just with:

<li><asp:HyperLink id="hlToDoList" runat="server" NavigateUrl="ContactManagementToDoList.aspx" Text="To Do List" /></li>

Open in new window

            if (reader.Read())
            {
				***blink here
				hlToDoList.CssClass = "blink";
            }

Open in new window

0
mcrmgAuthor Commented:
thank you very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.