⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chat.aspx

📁 一个 用Ajax实现聊天室的简单例子 不全的地方指点
💻 ASPX
字号:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chat.aspx.cs" Inherits="Chat" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!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 id="Head1" runat="server">
    <title>无标题页</title>
    <style type="text/css">
    .headerBg{cursor:hand;width:160px;height:30px;color:blue;font-weight:bold;text-align:center; background-image:url(Images/leftmenubg.gif);line-height:30px}
    </style>
</head>
<body style="background:#e7f7de" >
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        &nbsp;
        <asp:Label ID="lblTitle" runat="server" ForeColor="#0000C0" Height="35px" Style="left: 202px;
            position: relative; top: 6px" Width="478px"></asp:Label><br />
        <asp:Button ID="btnExit" runat="server" Style="left: 892px; position: relative; top: -20px"
            Text="退出程序" OnClick="btnExit_Click" /><br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
    </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table style="position: relative; height: 300px; left: 0px; width: 327px; top: 0px;">
                <tr>
                    <td style="width: 228px; height: 319px;">
                        <asp:Panel ID="Panel1" runat="server" Height="345px" Style="left: -2px; position: relative;
                            top: 3px" Width="218px">
                            <cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="headerBg">
                            </cc1:Accordion>
                        </asp:Panel>
                        <asp:Panel ID="Panel5" runat="server" Height="116px" Style="left: 3px; position: relative;
                            top: 10px" Width="210px">
                            <asp:Image ID="imgFace" runat="server" Height="63px" Style="left: 11px; position: relative;
                                top: 9px" Width="76px" />
                            <asp:Label ID="lblUser" runat="server" Style="left: 29px; position: relative; top: -30px"
                                Text="Label" Width="81px"></asp:Label>

                            <br />
                            <asp:LinkButton ID="btnUpdate" runat="server" PostBackUrl="~/Errol.aspx" Style="left: 16px;
                                position: relative; top: 18px">修改资料</asp:LinkButton>
                            <asp:LinkButton ID="btnSearch" runat="server" Style="left: 20px; position: relative;
                                top: 18px">交友中心</asp:LinkButton><br />
                        </asp:Panel>
                    </td>
                    <td style="width: 100px; height: 319px;">
                        <asp:Panel ID="Panel2" runat="server" Height="341px" Style="position: relative" Width="125px">
                            <asp:ImageButton ID="imgDirection" runat="server" Height="240px"
                                 Style="left: 30px; position: relative; top: 53px" Width="7px" />
                            <asp:Label ID="lblShow" runat="server" Height="81px" Style="left: 37px; position: relative;
                                top: -35px" Text="隐藏" Width="3px"></asp:Label></asp:Panel>
                    </td>
                </tr>
            </table>
            &nbsp;
            <cc1:CollapsiblePanelExtender id="CollapsiblePanelExtender1" runat="server" TargetControlID="Panel1" CollapseControlID="imgDirection" ExpandControlID="imgDirection" CollapsedImage="~/Images/toright.gif" ExpandedImage="~/Images/toleft.gif" CollapsedText="显示" TextLabelID="lblShow" ImageControlID="imgDirection" >
            </cc1:CollapsiblePanelExtender>
            &nbsp; &nbsp;&nbsp;
        </ContentTemplate>
        </asp:UpdatePanel>
        &nbsp;&nbsp;&nbsp;
        <asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
        </asp:Timer>
        <asp:Panel ID="Panel3" runat="server" Height="87px" Style="left: 370px; position: relative;
            top: -466px" Width="190px">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <table style="width: 650px; position: relative; height: 760px; left: 0px; top: -100px;">
                        <tr>
                            <td colspan="2" style="height: 264px">
                                <asp:Panel ID="Panel4" runat="server" Height="223px" ScrollBars="Auto" Style="left: 3px;
                                    position: relative; top: 3px" Width="636px">
                                    <asp:DataList ID="dlPublic" runat="server" Style="position: relative" CellPadding="4" ForeColor="#333333">
                                        <ItemTemplate>
                                            <table style="left: 0px; width: 613px; position: relative; top: 0px; height: 15px">
                                                <tr>
                                                    <td style="width: 27px; height: 30px">
                                                        <asp:Label ID="Label1" runat="server" ForeColor="#C00000" Style="position: relative"
                                                            Text='<%# Eval("fromTo.name")+" 对" %>' Width="121px"></asp:Label></td>
                                                    <td style="width: 127px; height: 30px">
                                                        <asp:Label ID="Label2" runat="server" ForeColor="#C000C0" Style="position: relative"
                                                            Text='<%# Eval("sendTo.name")+" 对" %>' Width="121px"></asp:Label></td>
                                                    <td style="width: 203px; height: 30px">
                                                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Style="left: 4px; position: relative;
                                                           top: 0px" Text='<%# Eval("content") %>' Width="191px"></asp:Label></td>
                                                    <td style="width: 136px; height: 30px">
                                                        <asp:Label ID="Label3" runat="server" Font-Italic="False" Font-Size="Smaller" ForeColor="Navy"
                                                            Text='<%# Eval("timer", "{0:g}") %>' Style="position: relative"  Width="130px"></asp:Label></td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                        <SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                                        <AlternatingItemStyle BackColor="White" />
                                        <ItemStyle BackColor="#FFFBD6" ForeColor="#333333" />
                                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                    </asp:DataList>
                                    </asp:Panel>
                                <asp:Panel ID="panPrivate" runat="server" Height="310px" ScrollBars="Auto" Style="left: 3px;
                                    position: relative; top: 9px" Width="636px" Visible="False">
                                    <asp:Label ID="lblPrivate" runat="server" Font-Italic="True" Font-Size="X-Large"
                                        ForeColor="Red" Height="32px" Style="left: 12px; position: relative; top: 14px"
                                        Text="您好的私人包厢已开启:" Width="302px"></asp:Label>
                                    <asp:DataList ID="dlPravite" runat="server" Style="position: relative; left: 1px; top: 18px;" CellPadding="4" ForeColor="#333333">
                                        <ItemTemplate>
                                            <table style="left: 0px; width: 613px; position: relative; top: 0px; height: 15px">
                                                <tr>
                                                    <td style="width: 27px; height: 30px">
                                                        <asp:Label ID="Label1" runat="server" ForeColor="#C00000" Style="position: relative"
                                                            Text='<%# Eval("fromTo.name")+" 对" %>' Width="121px"></asp:Label></td>
                                                    <td style="width: 127px; height: 30px">
                                                        <asp:Label ID="Label2" runat="server" ForeColor="#C000C0" Style="position: relative"
                                                            Text='<%# Eval("sendTo.name")+" 对" %>' Width="121px"></asp:Label></td>
                                                    <td style="width: 203px; height: 30px">
                                                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Style="left: 4px; position: relative;
                                                           top: 0px" Text='<%# Eval("content") %>' Width="191px"></asp:Label></td>
                                                    <td style="width: 136px; height: 30px">
                                                        <asp:Label ID="Label3" runat="server" Font-Italic="False" Font-Size="Smaller" ForeColor="Navy"
                                                            Text='<%# Eval("timer", "{0:g}") %>' Style="position: relative"  Width="130px"></asp:Label></td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                        <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                                        <AlternatingItemStyle BackColor="White" />
                                        <ItemStyle BackColor="#E3EAEB" />
                                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                    </asp:DataList>
                                    </asp:Panel>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 79px; height: 49px;">
                                <asp:Label ID="lblFriend" runat="server" Height="20px" Style="left: 19px; position: relative;top: 18px" Text="发送对象"  Width="114px"></asp:Label>
                            <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtFriend" 
                                 ServicePath="WebService.asmx" ServiceMethod="fuzzySearch"  CompletionSetCount="10" MinimumPrefixLength="1">
                            </cc1:AutoCompleteExtender>
                                <asp:TextBox ID="txtFriend" runat="server" Style="border-left-style:none; border-right-style:none; border-top-style:none; left: 144px; position: relative;
                                    top: -9px"></asp:TextBox></td>
                            <td style="width: 100px; height: 49px;">
                                <asp:CheckBox ID="chkIsPublic" runat="server" Style="position: relative; left: 24px; top: -4px;" Text="是否启用私聊" AutoPostBack="True" OnCheckedChanged="chkIsPublic_CheckedChanged" Width="120px" /></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 109px">
                                内容
                                <asp:ImageButton ID="btnAccept" runat="server" Height="20px" ImageUrl="~/Images/az-finish.gif"
                                    Style="left: 442px; position: relative; top: -6px" Width="87px" OnClick="btnAccept_Click" />
                                <asp:TextBox ID="txtContent" runat="server" Height="63px" Style="left: -80px; position: relative;
                                    top: -3px" TextMode="MultiLine" Width="412px"></asp:TextBox></td>
                        </tr>
                    </table>
                </ContentTemplate>
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>
        &nbsp;
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -