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?
 
Snarf0001Connect With a Mentor Commented:
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
 
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
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
 
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:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.