日期:2014-05-20  浏览次数:20408 次

[求助]数据写入无效?
在用AJAX实现一个聊天室~但是在提交文本框输入的内容后,却没写入相应的表里~


存储过程:

CREATE   PROCEDURE   [dbo].[SendNewMsg]--获取输入的信息  
(

@content   varchar(300),
@user_to   varchar(50),
@username   varchar(50),
@face   varchar(50),
@color   varchar(50)
)

AS  

insert   into   [Chat_Info]   (content,user_from,user_to,face,color,composetime)   values   (@content,@username,@user_to,@face,@color,Getdate())
GO

============================================

WebForm1.aspx:

<%@   Page   language= "c# "   Codebehind= "WebForm1.aspx.cs "   AutoEventWireup= "false "   Inherits= "MyChatRoomTest.WebForm1 "   %>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN "   >
<HTML>
    <HEAD>
<title> WebForm1 </title>
<meta   name= "GENERATOR "   Content= "Microsoft   Visual   Studio   .NET   7.1 ">
<meta   name= "CODE_LANGUAGE "   Content= "C# ">
<meta   name= "vs_defaultClientScript "   content= "JavaScript ">
<meta   name= "vs_targetSchema "   content= "http://schemas.microsoft.com/intellisense/ie5 ">

<script   language= "jscript ">
////////////////////====下面的FUNCTION就是把文本框的内容写入到表里====////////
function   SendNewMsg()
{
var   txtContent   =document.all( "content ");
if(txtContent== " ")return;
var   user_to=document.all( "user_to ").value;
var   face=document.all( "face ").value;
var   color=document.all( "color ").value;


WebForm1.SendNewMsg(txtContent,user_to,face,color);
       
document.all( "content ").value= " ";//清空输入框;

} </script>
</HEAD>
<body   MS_POSITIONING= "GridLayout ">

<form   id= "Form2 "   method= "post "   runat= "server ">
<FONT   face= "宋体 "> </FONT>
<table   width= "747 "   height= "719 "   border= "1 ">
<tr>
<td   width= "141 "   height= "659 "> &nbsp; </td>
<td   width= "590 "> <div   id= "chatcontent ">
欢迎来到聊天室~
</div>
&nbsp; </td>
</tr>
<tr>
<td   height= "52 "   colspan= "2 "> <form   id= "form1 "   name= "form1 "   method= "post ">
<input   type= "text "   name= "content "   onkeydown= "if   (event.keyCode   ==   13)   {SendNewMsg();return   false;} "> <!--此为按ENTER即发送的方法   -->


表情
<select   name= "face ">
<option   value= "笑着 "   selected>
笑着 </option>
</select>
发往
<select   name= "user_to ">
<option   value= "大家 "   selected> 大家 </option>
</select>