页面部分
代码如下:
<asp:ScriptManager ID="ScriptManager
" runat="server">
</asp:ScriptManager>
<h
>
使用VS控件updatePanel实现无刷新
</h
>
<p>
<asp:UpdatePanel ID="UpdatePanel
" RenderMode="Block" UpdateMode="Conditional" runat="server">
<ContentTemplate>
点击按钮从服务器获取当前时间<asp:TextBox ID="txtTime" runat="server"></asp:TextBox>
<asp:Button ID="btn
" runat="server" Text="Button" onclick="btn
_Click" />
</ContentTemplate>
<Triggers>
<%
<asp:PostBackTrigger ControlID="btn
" />
%>
<asp:AsyncPostBackTrigger ControlID="btn
"/>
</Triggers>
</asp:UpdatePanel>
</p>
后台代码
代码如下:
protected void btn
_Click(object sender
EventArgs e)
{
txtTime
Text = DateTime
Now
ToString();
}