updatepanel问题,急
应该不是代码问题,代码很简单:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>UpdatePanel Simple</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat ="server"/>
Page Time: <%= DateTime.Now.ToString("T") %>
<br /><br />
<asp:UpdatePanel
id="up1"
runat="server">
<ContentTemplate>
UpdatePanel Time <%= DateTime.Now.ToString("T") %>
<br />
<asp:Button
id="btn"
Text="Update"
runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<div>
</div>
</form>
</body>
</html>
问题:
点按钮页面不刷新,我的是visual studio 2010 trail版 ,不知道会不会有影响,还是我哪里配置有问题,
网上说web.config里面需要加:
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
我加了之后依然不起作用
求高手帮忙解答
------解决方案--------------------你用了updatepanel页面不会回传,当然就不会刷新了
------解决方案--------------------你这是局部更新,只有updatepanel里面的控件才会更新
------解决方案--------------------
UpdatePanel Time是会更新的
要想 Page Time也更新的话,把Triggers标签添加上:
C# code
<asp:UpdatePanel
id="up1"
runat="server">
<ContentTemplate>
UpdatePanel Time <%= DateTime.Now.ToString("T") %>
<br />
<asp:Button
id="btn"
Text="Update"
runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btn" />
</Triggers>
</asp:UpdatePanel>