Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET buttons
I am trying to create a page for multiple users to chat with each other. So i chanced upon this great tutorial which has given me what i wanted. Here's the link reference: Multi User Chat Room Using ASP.NET 2.0 and AJAX[^]
 
However, the Send button was not firing any action and messages were not posted in the textbox as shown in the tutorial. Every other details worked fine. I do not really know where is the problem as when i debug, no error was shown.
 
Here's the Chat.aspx page:
<div  önunload="Leave()">
<input id="hdnRoomID" type="hidden" name="hdnRoomID" runat="server"/>
        <asp:ScriptManager ID="ScriptManager1" runat="server"  EnablePartialRendering="True" EnablePageMethods="True">
            <Scripts>
                <asp:ScriptReference Path="scripts.js" />
            </Scripts>
        </asp:ScriptManager>
        
        
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td width="80%">
                            <asp:textbox runat="server" TextMode="MultiLine" id="txt" style="Width: 690px; HEIGHT: 260px" rows="16" Columns="79" ></asp:textbox>
                    <br />
                   <asp:TextBox id="txtMsg" Width="400" Runat="server"></asp:TextBox> <input id="btn" onclick="button_clicked()" type="button" value="SEND" />
                </td>
                <td width="20%" rowspan="2" valign="top">
                    Room Members <br />
                             
                            
                            <asp:ListBox runat="server" Width="100" ID="lstMembers" Enabled="false" Height="249px"></asp:ListBox>
                    
                </td>
            </tr>
        </table>
</div>
 
The onclick send button was fired here in a scripts.js:
function button_clicked() {
    PageMethods.SendMessage($get("txtMsg").value, $get("hdnRoomID").value, UpdateMessages, errorCallback);
    $get("txtMsg").value = "";
    $get("txt").scrollIntoView("true");
}
function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object') {
        if (navigator.appName.indexOf("Netscape") > (-1)) {
            if (e.keyCode == 13) {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}
Posted 11-Jul-13 6:55am
kellycx745
Comments
kellycx at 21-Jul-13 9:04am
   
I managed to solved it myself

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 504
1 Maciej Los 349
2 Kornfeld Eliyahu Peter 325
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100