Reputation: 812
I have script manager in master page:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptLocalization ="true" EnableScriptGlobalization ="true" EnablePartialRendering="true" >
</asp:ScriptManager>
MyPage.aspx (Placed in contentplaceholder of master page)
<asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional" EnableViewState="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRefresh" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:PlaceHolder ID="placeHolder1" runat="server" EnableViewState="true"></asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
MyPage.aspx script:
$(document).ready(function () {
setInterval(myfun, 20000);
});
function myfun() {
var btn = document.getElementById('<%=btnRefresh.ClientID%>');
btn.click();
}
On the place holder I'm putting dynamically created table containing user controls. On the page load, I can see the user controls on the page. But when Async postback is called after 20 seconds, I don't see the user controls. With firebug, I see that user controls are there. But they do not get rendered; even though I'm creating them again on async postback. They appears to be empty. Help.
Upvotes: 0
Views: 881
Reputation: 22076
Try this code. You need to create controls on every page postback.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetData(); // get data from database
}
LoadUserControls(); // Create dynamic table containing user controls
}
I think you should read this. Loading UserControl Dynamically in UpdatePanel
Upvotes: 1