Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,
I placed an update panel for periodic updates in a content page but when I run the program nothing happened. nither a full page postback nor a partial postback. my content page html is
ASP.NET
<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>
                      A New visitor come from <%#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
C#
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();
}
Posted
Updated 27-Aug-13 22:22pm
v2
Comments
[no name] 28-Aug-13 4:57am    
Other wise use ispostback method in pageload!
Member 10198825 28-Aug-13 5:27am    
I tried it but it don.t do anything

1 solution

Try taking this part...

XML
<Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>


Out of your code...

You didn't specify a condition on the panel so the timer will automatically do a postback on the ontick event...
 
Share this answer
 
Comments
Member 10198825 29-Aug-13 1:30am    
I try this but by removing trigger from update panel how can i update it
Dave963 29-Aug-13 5:41am    
If you have an updatepanel where you don't specify the UpdateMode all the control in your update panel that causes a post back will only update the content inside your update panel... So the OnTick event of your timer inside your update panel will update the update panel... You just have to specify what you want to update in your OnTick event on your c# side...
Dave963 29-Aug-13 5:44am    
A week ago I had the same problem, when I add a trigger for the timer it doesn't work but when i just took out my trigger part it worked perfectly. Hope this helps...
Member 10198825 29-Aug-13 6:59am    
Ok I will try it , is there any other method unig javascript to parial postback the update panel
Dave963 30-Aug-13 8:06am    
Yes there is, but you will be writing more code yourself instead of just dragging the timer on the form...

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