Re: The chat does not works

  •  09-27-2012, 7:34 AM

    Re: The chat does not works

    Hi,

     

    You can try the example page below, it will get all chat rooms and shows it in the page like demo http://dotnetdate.com/Chat.aspx

     

    1. <%@ Import Namespace="CuteChat" %>  
    2. <%@ Import Namespace="System.Data" %>  
    3. <%@ Import Namespace="System.Data.SqlClient" %>  
    4.   
    5. <%@ Page Language="c#" %>  
    6.   
    7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    8. <html>  
    9. <head>  
    10.     <title>chat room</title>  
    11. </head>  
    12. <body>  
    13.     <form id="Form1" method="post" runat="server">  
    14.         <div class="infobox" style="width: 700px; margin: 30px auto">  
    15.             <h2>  
    16.                 Chat  
    17.             </h2>  
    18.             <div class="padding10">  
    19.                 <table cellspacing="0" border="0" cellpadding="8" style="width: 90%">  
    20.                     <tr>  
    21.                         <td>  
    22.                             <asp:DataList ID="DataList_Lobbies" CellSpacing="3" Width="400" RepeatColumns="2"  
    23.                                 runat="server">  
    24.                                 <ItemTemplate>  
    25.                                     <asp:HyperLink ID="lnkLobby" runat="server">  
    26.                                                             <nobr><img src="images/home.gif" width="49" height="49" border="0" align="middle"><%#DataBinder.Eval(Container.DataItem, "Name")%></nobr>  
    27.                                     </asp:HyperLink>  
    28.                                     <br />  
    29.                                     (  
    30.                                     <asp:Label ID="lblOnlineChater" runat="server"></asp:Label>  
    31.                                     chatting)  
    32.                                 </ItemTemplate>  
    33.                             </asp:DataList>  
    34.                             <asp:Literal ID="Literal1" runat="server" />  
    35.                         </td>  
    36.                         <td>  
    37.                             <img alt="" src="images/cutechat_picture.jpg" height="180" />  
    38.                         </td>  
    39.                     </tr>  
    40.                 </table>  
    41.             </div>  
    42.         </div>  
    43.     </form>  
    44.   
    45.     <script runat="server">  
    46.           
    47.         private void Page_Load(object sender, System.EventArgs e)  
    48.         {  
    49.             if (!this.IsPostBack)  
    50.             {  
    51.                 ArrayList lobbies = new ArrayList();  
    52.                 foreach (LobbyInfo lobby in ChatApi.GetLobbyInfoArray())  
    53.                 {  
    54.                     if (lobby.Lobby.Integration == "" || lobby.Lobby.Integration == null)  
    55.                         lobbies.Add(lobby);  
    56.                 }  
    57.                 this.DataList_Lobbies.DataSource = lobbies;  
    58.                 this.DataList_Lobbies.ItemDataBound += new DataListItemEventHandler(rptLobbies_ItemDataBound);  
    59.                 this.DataList_Lobbies.DataBind();  
    60.             }  
    61.   
    62.             if (CuteChat.ChatApi.GetLobbyInfoArray().Length < 1)  
    63.                 Literal1.Text = "<p style='font-size:14px;'>There is no chat room availables now.<br><br>Please login as admin and create chat rooms in the admin console!</p>";  
    64.         }  
    65.   
    66.   
    67.         private void rptLobbies_ItemDataBound(object sender, DataListItemEventArgs e)  
    68.         {  
    69.             if (e.Item.DataItem == null)  
    70.             {  
    71.                 return;  
    72.             }  
    73.   
    74.             LobbyInfo lobby = (LobbyInfo)e.Item.DataItem;  
    75.             HyperLink lnkLobby = e.Item.FindControl("lnkLobby"as HyperLink;  
    76.             lnkLobby.NavigateUrl = CuteChat.ChatWebUtility.ResolveResource(this.Context, "Channel.Aspx") + "?Place=Lobby-" + lobby.Lobby.LobbyId;  
    77.             lnkLobby.Target = "_blank";  
    78.             String sOnlineChater = lobby.JoinClient(",");  
    79.             Label lblOnlineChater = e.Item.FindControl("lblOnlineChater"as Label;  
    80.             lblOnlineChater.Text = lobby.ClientCount.ToString();  
    81.             lnkLobby.ToolTip = sOnlineChater;  
    82.         }  
    83.   
    84.     </script>  
    85.   
    86. </body>  
    87. </html>  
     

    Regards,

     

    Ken 

View Complete Thread