在几秒钟内连续刷新转发器控制

时间:2014-12-30 05:52:00

标签: c# asp.net repeater

我正在asp.net c#上做社交网络服务。我想在1秒内刷新消息而不加载整个页面。我正在使用转发器控件显示消息。

我希望在1秒后连续刷新此转发器控件,但不应重新加载整页。

转发器控制代码

setInterval(function () { $(".refresh").load(location.href + " .refresh"); }, 1000);

<asp:Repeater runat="server" ID="Repeater1">
 <ItemTemplate>




     <div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px;  width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                    <div style="width: 58px; height: 40px">
                    <asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
                        </div>
                    <div style="width: 307px;  margin-left: 65px; margin-top: -60px">
                        <asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderID") %> </asp:Label>
                    </div>
                    <div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;">&nbsp;<asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
                    </div>
                    &nbsp;<div style="margin-left: 350px">
                        <asp:Label ID="Label11" runat="server"  Text="Posted on: " Font-Size="Small"><%#Eval("Time") %> </asp:Label>
                    </div>
                </div>




 </ItemTemplate>

文本框代码

<asp:TextBox ID="Message" runat="server" OnTextChanged="TextBox3_TextChanged" style="margin-left: 12px; text-align: left;" TextMode="MultiLine" Width="564px" Height="100px"></asp:TextBox>

1 个答案:

答案 0 :(得分:0)

希望这会有所帮助:

 <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"   CodeBehind="Trans.aspx.cs" Inherits="WebClient.WebForm1" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script>
 $(document).ready(
        function() {
            setInterval(function () { $('#Repeater1').load(location.href + " #Repeater1"); }, 1000);
        });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>


 <div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px;  width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <br />
                <div style="width: 58px; height: 40px">
                <asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
                    </div>
                <div style="width: 307px;  margin-left: 65px; margin-top: -60px">
                    <asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderID") %> </asp:Label>
                </div>
                <div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;">&nbsp;<asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
                </div>
                &nbsp;<div style="margin-left: 350px">
                    <asp:Label ID="Label11" runat="server"  Text="Posted on: " Font-Size="Small"><%#Eval("Time") %> </asp:Label>
                </div>
            </div>




</ItemTemplate>
</asp:Repeater>
</asp:Content>