首页 新闻 会员 周边

用UpdatePanel实现 点击查询按钮时让table里边的文本框不刷新,该怎么嵌套?

0
悬赏园豆:30 [已解决问题] 解决于 2012-09-28 16:16

 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
 <ContentTemplate>

 

  //这中间放文本框和按钮?按钮是服务器端的。

</ContentTemplate>

</asp:UpdatePanel>

做梦乐醒的狗狗的主页 做梦乐醒的狗狗 | 初学一级 | 园豆:81
提问于:2012-08-31 10:58
< >
分享
最佳答案
0

 你想在点击查询按钮时让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>
收获园豆:30
眯妖 | 小虾三级 |园豆:820 | 2012-09-01 10:13
其他回答(1)
0

表格  文本框 按钮  都放中间

暗尘掩月 | 园豆:183 (初学一级) | 2012-08-31 11:02

整个table吗?我放了,不行

支持(0) 反对(0) 做梦乐醒的狗狗 | 园豆:81 (初学一级) | 2012-08-31 11:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册