user2660030
user2660030

Reputation:

update panel is not working

I placed a data bound control inside update panel. and sets a timer which refrshes it in every 5 seconds. but it is not updating the div inside th update panel. for updating data i have to refreshe the whole page.I am using it in master page.myhtml code is

 <asp:ScriptManager ID="ScriptManager1" runat="server">
 </asp:ScriptManager>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Timer ID="Timer1" runat="server" Interval="5000" ontick="Timer1_Tick">
        </asp:Timer>
        <br />
        <div style="height:480px;overflow:scroll;">
        <asp:Repeater ID="Repeater1" runat="server">
       <ItemTemplate>

                   <div id="message" >
                   <img id="image" alt="visitors" runat="server" src="~/icon-visitors.png" height="32" width="32" /></td><td>
                      <b>A New visitor come from </b><b class="data"><%#Eval("lt_country") %>
</ItemTemplate>
            </asp:Repeater>
           <button id="btn1" style="visibility:visible;">yiui</button>
           </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
    </asp:UpdatePanel>

and c# code is

 protected void Page_Load(object sender, EventArgs e)
{
   // Page.ClientScript.RegisterStartupScript(this.GetType(), "http://localhost:49415/WebSite5/panel_advertiser/adver_files/js/JScript.js", "alert('hello world!');");
    add();
    Rep_Bind();
}
private void Rep_Bind()
{   
      objprop.Query = "select lt_country,lt_browser,lt_ip,pk_id from log_unique where lt_username='myfunline' order by pk_id desc limit 3";
      MySqlDataAdapter adp = new MySqlDataAdapter(objprop.Query, ConfigurationManager.AppSettings["constring"].ToString());
      DataSet ds = new DataSet();
      adp.Fill(ds);
      Repeater1.DataSource = ds;
      Repeater1.DataBind();
}
protected void Timer1_Tick(object sender, EventArgs e)
{

   // ClientScript.RegisterClientScriptBlock(this.GetType(), "blah", "http://localhost:49415/WebSite5/panel_advertiser/adver_files/js/JScript.js", false);
    Rep_Bind();
}

Edited body

Upvotes: 2

Views: 255

Answers (1)

user2660030
user2660030

Reputation:

I solve this by removing timer from update panel,and placing it outside the update panel

Upvotes: 1

Related Questions