2016-08-05 131 views
-1

更新面板控件不能在正常模式下工作,即当我在调试模式下浏览时没有进行调试时,它工作得很好。UpdatePanel只能在调试模式下工作

我的代码如下 -

<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"> 
<ContentTemplate> 
<asp:Timer runat="server" id="Timer1" Interval="5000"></asp:Timer> 

<%-- web content here --%> 

</ContentTemplate> 
</asp:UpdatePanel> 

请建议在正常模式下上述的工作无需调试。 在此先感谢。

回答

0
`<head runat="server"> 
<title></title> 
<meta http-equiv="refresh" content="10" /> 
</head> 

<body> 
<form id="form1" runat="server"> 
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"> 
<ContentTemplate> 
<%-- web content here --%> 
</ContentTemplate> 
</asp:UpdatePanel> 
</form> 
</body> 
</html> 

in .cs page i used 
protected void Page_Load(object sender, EventArgs e) 
{ 
    UpdatePanel1.Update(); 
}` 

我用简单的meta标签在标签下的德兴页面上,刷新页面

+0

我不愿刷新整个页面。我的要求是每隔10秒从数据库中获取更改的属性而不刷新它。 –

0

META标签将刷新整个页面,调用Page_Load方法之前,其工作的罚款。

我还注意到,在.NET4.5之后,updatepanels也停止了工作。也许它是一个框架中的错误,或者可能是阻止它的东西。当你在项目中使用bootstrap的时候更糟糕。由于UpdatePanels是脚本驱动的,因此一些隐藏的引导脚本可能会干扰它。

所以,如果它没有太多的麻烦,你可以使用jQuery连接所有的事件,并且你需要进行服务器调用,你可以使用ajax来调用一个项目托管的web服务。这样,除非你想要,否则你的页面根本不会加载。

相关问题