Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

simple ajax user control which updates timely

Avatar of dotnet0824
dotnet0824 asked on
.NET ProgrammingASP.NET
12 Comments1 Solution679 ViewsLast Modified:

I created a v simple user control using ajax updatepanel.
and called it in a asp.net page. it works fine but looks like usercontrol doesnot refresh. I added new records to check
but i am not sure whats wrong I am doing.

UserControl Design Code

<div style="padding-top: 0px">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                &nbsp;<asp:Label id="ltlctrl"  Width="30%" Height="18px"  runat="server"></asp:Label>
                <asp:Timer ID="Timer1" runat="server" Interval="10" OnTick="Timer1_Tick1">
        <br />

============================Code behind in userControl==================
private void Page_Load(object sender, System.EventArgs e)


    public void GetNews()
        // Put user code to initialize the page here

        SqlConnection myCon = new SqlConnection("server=TEST;DATABASE=SA_USER;USER ID=sa;password=;");

        string strSql = "SELECT top 5 *  FROM tbl_News order by dateCreated asc";

        string strScrolling = "";

        HtmlTableCell cellScrolling = new HtmlTableCell();

        SqlCommand myComd = new SqlCommand(strSql, myCon);

        SqlDataReader sqlRdr;



            sqlRdr = myComd.ExecuteReader();

            strScrolling = "<Marquee OnMouseOver='this.stop();' OnMouseOut='this.start();' direction='up'   scrollamount='2' bgcolor='blue' width='80%'>";

            while (sqlRdr.Read())

                strScrolling = strScrolling + "<a href='#' OnClick=" + "javascript:window.open('newsDetail.aspx?NewsId=" + sqlRdr.GetValue(0) + "','NewsDetail','width=400,height=400;toolbar=no;');" + "><font  face='verdana' size='2' color='#ffffff'>" + sqlRdr.GetValue(1) + "</a>&nbsp;&nbsp;" + sqlRdr.GetValue(2).ToString() + "</font><br><br>";

            strScrolling = strScrolling + "</Marquee>";

            ltlctrl.Text = strScrolling;

            //cellScrolling.InnerHtml = strScrolling;



        catch (Exception ex)

            throw (ex);



            //close sql connection    



    protected void Timer1_Tick1(object sender, EventArgs e)
===========================ASP.NET Page added that user Control--------------------
<%@ Register TagPrefix="uc1" TagName="links" Src="Ticker.ascx" %>
<!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>Untitled Page</title>
    <form id="form1" runat="server">
    <uc1:links ID="link1" runat="server" />
Avatar of imayknowit
imayknowitFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers