Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am creating a birthday screen where I need to display Bday images as background and also to display employee details on Bday date...

As a result all details with background will display. But the only thing is background flickers every time of timer rotation..
How to solve the flickering???

Please do the needful team...

C#
Here is my Code:


        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    CompID = objGlobal.HRCompanyID;
                    BindNextImage();
                }
             

            }

            catch (Exception ex)
            {
               
            }
            return;


        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            BindNextImage();
        }


        public void BindNextImage()
        {
            try
            {
                ClearControls();
                Random _rand = new Random();
                dtData = objTvImage.getImage(CompID);
                int i = _rand.Next(0, dtData.Rows.Count);

                lblCompName.Text = dtData.Rows[i]["CompanyName"].ToString();
                lblDepName.Text = dtData.Rows[i]["Department"].ToString();
                lblEmpName.Text = dtData.Rows[i]["Name"].ToString();
                lblMonth.Text = dtData.Rows[i]["Designation"].ToString();
                lblDate.Text = dtData.Rows[i]["Date Of Birth"].ToString();
                GetImage((byte[])dtData.Rows[i]["Image"]);

                //To get templates

                if (lblDate.Text == "TRANSFER")
                {
                    pnlImage.BackImageUrl = "~/Images/" + "TRAN.jpg";
                }
                else if (lblDate.Text == "PROMOTED")
                {
                    pnlImage.BackImageUrl = "~/Images/" + "PRO.jpg";
                }
                else
                {
                    int day = (int)System.DateTime.Now.Day;
                    pnlImage.BackImageUrl = "~/Images/" + "BDay" + day.ToString() + ".jpg";
                }


            }

            catch (Exception ex)
            {
            }
        }

    }


What I have tried:

Please refer the above code..
Posted
Updated 28-Mar-16 1:52am
v3
Comments
[no name] 19-Mar-16 8:00am    
You can use javascript built-in function setInterval() to call methods which will display Bday image. If you want to get data from server then send AJAX request and display them.
Member 12403164 19-Mar-16 8:51am    
Please find any Jscript for that..
Member 12403164 19-Mar-16 8:51am    
:)
Member 12403164 26-Mar-16 7:44am    
Any Solution for this?

1 solution

Probably, it's not the timer itself, but the way you are displaying the data that is causing the problem - and without seeing your code we can't tell you what to do to fix it. If all you are doing in the timer is Invalidating the form or the panel, then that could cause the flicker as the background is erased and redrawn, for example.

You may be able to reduce or eliminate the problem by setting the Form.DoubleBuffered property to true, but I'd start by looking at teh code you use to draw things when the Timer.Tick happens.
 
Share this answer
 
Comments
Member 12403164 26-Mar-16 7:44am    
Any Solution for this?

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