How to refresh a part of the page after some time automatically?
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
精彩评论