发送按钮未触发以在文本框中发布消息 [英] Send button not firing to post the message in the textbox
问题描述
我正在尝试为多个用户创建一个页面,以便彼此聊天。所以我偶然发现了这个很棒的教程,它给了我想要的东西。以下是链接参考: 使用ASP.NET 2.0和AJAX的多用户聊天室 [ ^ ]
但是,发送按钮没有触发任何操作,消息没有发布在文本框中,如教程中所示。其他细节都很好。我真的不知道问题在哪里,因为我调试时没有显示错误。
这是Chat.aspx页面:
<divönunload= 离开() >
<输入id = hdnRoomID type = hidden name = hdnRoomID runat = server />
< asp:ScriptManager ID = ScriptManager1 runat = server EnablePartialRendering = True EnablePageMethods = True >
< Scripts>
< asp:ScriptReference Path = scripts.js />
< / 脚本 >
< / asp:ScriptManager >
< table cellpadding = 0 cellspacing = 0 >
< tr>
< td width = 80% >
< asp:textbox runat = server TextMode = MultiLine id = < span class =code-string> txt style = 宽度:690px;高度:260px rows = 16 Columns = 79 > < / asp:textbox >
< br />
< asp:TextBox id = txtMsg Width = 400 Runat = 服务器 > < / asp:TextBox > < input id = btn onclick = button_clicked() type = 按钮 value = 发送 />
< / td >
< td width = 20% rowspan = 2 valign = top >
会员< br />
< asp:ListBox runat = server宽度= 100 ID = lstMembers已启用= false高度= 249px > < / asp:ListBox >
< / td >
< / tr >
< / 表格 >
< / div >
onclick发送按钮在这里用scripts.js解雇:
function button_clicked(){
PageMethods.SendMessage($ get( txtMsg) 。 value ,$ get( hdnRoomID)。 value ,UpdateMessages,errorCallback);
$ get( txtMsg)。 value = ;
$ get( txt)。scrollIntoView( true);
}
函数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 ;
}
}
}
}
get( txtMsg)。 value ,
get( hdnRoomID)。 value ,UpdateMessages,errorCallback);
get( txtMsg)。 value = 跨度>;
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;
}
}
}
}
get("txtMsg").value,
get("hdnRoomID").value, UpdateMessages, errorCallback);
get("txtMsg").value = "";
这篇关于发送按钮未触发以在文本框中发布消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!