troubleshooting Question

simple ajax user control which updates timely

Avatar of dotnet0824
dotnet0824 asked on
.NET ProgrammingASP.NET
12 Comments2 Solutions679 ViewsLast Modified:

I created a v simple user control using ajax updatepanel.
and called it in a 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=" + "'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" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <uc1:links ID="link1" runat="server" />

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

Join our community to see this answer!
Unlock 2 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros