关闭

一个Div导致Ajax中UpdatePanel以外的数据执行操作的时候全部消失2012-03-25 10:05

标签: divajaxaspservertriggersclass
572人阅读 评论(0) 收藏 举报
分类:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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></title>

    <style type="text/css">
        .style1
        {
            width: 824px;
        }
        .style2
        {
            width: 158px;
        }
        .style3
        {
            width: 305px;
        }
    </style>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div>
                <asp:TextBox ID="txtSay" runat="server" Height="117px" TextMode="MultiLine" Width="359px"></asp:TextBox><br />
            </div>
          <%-- <div> --%>
                 浏览总数: <asp:Label ID="asdf" runat="server" Text="Label" Font-Bold="True" Font-Size="Larger"
                    ForeColor="#CC0000" ></asp:Label>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="884px">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <table class="style1">
                                    <tr>
                                        <td style="background-color: #eee;" class="style3">
                                            昵称:<%# Eval("username") %></td>
                                    </tr>
                                    <tr>
                                        <td style="background-color: Aqua;" class="style3">
                                            内容:<%# Eval("content") %></td>
                                    </tr>
                                    <tr>
                                        <td class="style3">
                                            时间:<%# Eval("timespan")%>分钟之前
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="link1" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link2" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link3" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link4" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
 
             <asp:Button ID="btn1" runat="server" Text="Button" onclick="btn1_Click" />
            <asp:LinkButton ID="link1" runat="server" OnClick="LinkButton1_Click">第一页</asp:LinkButton>
            <asp:LinkButton ID="link2" runat="server" OnClick="LinkButton2_Click">下一页</asp:LinkButton>
            <asp:LinkButton ID="link3" runat="server" OnClick="LinkButton3_Click">上一页</asp:LinkButton>
            <asp:LinkButton ID="link4" runat="server" OnClick="LinkButton4_Click">末页</asp:LinkButton>
  

    </form>
    </body>
</html>

 

以上是正确的执行的

以下是出现问题的:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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></title>

    <style type="text/css">
        .style1
        {
            width: 824px;
        }
        .style2
        {
            width: 158px;
        }
        .style3
        {
            width: 305px;
        }
    </style>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div>             <%-- <问题所在就是这里> --%> 

                <asp:TextBox ID="txtSay" runat="server" Height="117px" TextMode="MultiLine" Width="359px"></asp:TextBox><br />
            </div>
              <div>    

                 浏览总数: <asp:Label ID="asdf" runat="server" Text="Label" Font-Bold="True" Font-Size="Larger"
                    ForeColor="#CC0000" ></asp:Label>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="884px">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <table class="style1">
                                    <tr>
                                        <td style="background-color: #eee;" class="style3">
                                            昵称:<%# Eval("username") %></td>
                                    </tr>
                                    <tr>
                                        <td style="background-color: Aqua;" class="style3">
                                            内容:<%# Eval("content") %></td>
                                    </tr>
                                    <tr>
                                        <td class="style3">
                                            时间:<%# Eval("timespan")%>分钟之前
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="link1" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link2" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link3" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="link4" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
 
             <asp:Button ID="btn1" runat="server" Text="Button" onclick="btn1_Click" />
            <asp:LinkButton ID="link1" runat="server" OnClick="LinkButton1_Click">第一页</asp:LinkButton>
            <asp:LinkButton ID="link2" runat="server" OnClick="LinkButton2_Click">下一页</asp:LinkButton>
            <asp:LinkButton ID="link3" runat="server" OnClick="LinkButton3_Click">上一页</asp:LinkButton>
            <asp:LinkButton ID="link4" runat="server" OnClick="LinkButton4_Click">末页</asp:LinkButton>
  

    </form>
    </body>
</html>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:162415次
    • 积分:2828
    • 等级:
    • 排名:第12643名
    • 原创:118篇
    • 转载:4篇
    • 译文:1篇
    • 评论:21条
    文章分类
    最新评论