更新面板无法正常工作 [英] update panel not working
本文介绍了更新面板无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
我在内容页面中放置了一个更新面板以定期更新,但是当我运行该程序时没有任何反应。既不是整页回发也不是部分回发。我的内容页面html是
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: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>
和c#代码是
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();
}
推荐答案
试试这部分...
Try taking this part...
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
代码不...
您没有在面板上指定条件,因此计时器将自动对ontick事件进行回发...
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...
这篇关于更新面板无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文