你想在点击查询按钮时让table里边的文本框不刷新,那你想实现的就是局部刷新
C#: using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial class Test : System.Web.UI.Page { public string RetrunHtml; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { RetrunHtml = "<table><tr><td>不需要刷新的内容哦</td></tr></table>"; } } protected void btnSelect_Click(object sender, EventArgs e) { Label1.Text = System.DateTime.Now.ToString(); } } HTML: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %> <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Button ID="btnSelect" runat="server" Text="查询" onclick="btnSelect_Click" /> <div style="border:solid 1px red; width:300px; height:100px"> <%-- 这里放你的table,也就是你不需要刷新的内容--%> <%=RetrunHtml %> </div> <div style="margin-top:20px;border:solid 1px Blue; width:300px; height:100px"> <asp:UpdatePanel id="UpdatePanel1" UpdateMode="Conditional" runat="server"> <ContentTemplate> <%--这里放你要刷新的内容--%> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnSelect" /> </Triggers> </asp:UpdatePanel> </div> </div> </form> </body> </html>
表格 文本框 按钮 都放中间
整个table吗?我放了,不行