开发者

How to refresh a part of the page after some time automatically?

开发者 https://www.devze.com 2023-03-20 09:32 出处:网络
I have a user control loaded on the default.aspx page using the Control UControl = null; U开发者_Python百科Control = this.LoadControl(\"UserControl1.ascx\");

I have a user control loaded on the default.aspx page using the

Control UControl = null;

U开发者_Python百科Control = this.LoadControl("UserControl1.ascx");

 UControl.ID = UControl.GetType().Name;
                    panel1.Controls.Add(UControl);

Now I want to refresh only the content of the user control not all the page.

I already used

<meta http-equiv="refresh" content="300">

and

Response.AppendHeader("Refresh", "2");

But these are refreshing the entire default.aspx page.

How I can only refresh the user control without refreshing the default.aspx.


You need to look into the <asp:UpdatePanel> control. You can use it with a timer as well to auto refresh, or hook it into a trigger such as button or link.

Try here on the offical asp.net site:

  • http://www.asp.net/ajax/tutorials/understanding-partial-page-updates-with-asp-net-ajax

But a simple search will also produce plenty of tutorials.


You can use the Ajax Timer Control: http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-timer-control

0

精彩评论

暂无评论...
验证码 换一张
取 消