JS中类的引用问题
我在ChatRoom类里面封转了一个方法SendMsg当我在JS里面用的时候是这样写的 ChatRoom.SendMsg(,,,);在未发布前没有问题,但是发布后提示ChatRoom未定义下面是代码JScript codefunction send() {
var txtContent = document.all("content").value;
alert('var txtContent = document.all("content").value;!');
if (txtContent == "") return;
alert('if (txtContent == "") return;');
var user_to = document.all("userlist").value;
alert('var user_to = document.all("userlist").value;');
var textcolor = document.all("textcolor").value;
alert('var textcolor = document.all("textcolor").value;');
var expression = document.all("expression").value;
alert('var expression = document.all("expression").value;');
var isPublic = !(document.all("isSecret").checked);
alert('var isPublic = !(document.all("isSecret").checked);');
ChatRoom.SendMsg(txtContent, user_to, textcolor, expression, isPublic);
alert('ChatRoom.SendMsg(txtContent, user_to, textcolor, expression, isPublic);');
var div = document.all("chatcontent");
alert('var div = document.all("chatcontent");');
div.innerHTML = ChatRoom.GetNewMsgString().value + div.innerHTML;
alert('div.innerHTML = ChatRoom.GetNewMsgString().value + div.innerHTML;');
document.all("content").value = "";
alert('document.all("content").value = "";');
}
C# code
[Ajax.AjaxMethod()]
public void SendMsg(string strMsg, string strUserTo, string strColor, string strExpression, bool bIsPublic)
{
Response.Write("<script language='JavaScript'>alert('public void SendMsg')</script>");
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
Response.Write("<script language='JavaScript'>alert('SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[].ConnectionString)')</script>");
SqlCommand cmd = new SqlCommand();
Response.Write("<script language='JavaScript'>alert('SqlCommand cmd = new SqlCommand();')</script>");
cmd.Connection = conn;
Response.Write("<script language='JavaScript'>alert('cmd.Connection = conn;')</script>");
cmd.CommandType = CommandType.StoredProcedure;
Response.Write("<script language='JavaScript'>alert('cmd.CommandType = CommandType.StoredProcedure;')</script>");
cmd.CommandText = "SendMsg";
Response.Write("<script language='JavaScript'>alert('cmd.CommandText = ;')</script>");
cmd.Parameters.Add("@user_from", UserName);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, UserName);')</script>");
cmd.Parameters.Add("@user_to", strUserTo);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, strUserTo);')</script>");
cmd.Parameters.Add("@content", strMsg);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, strMsg);')</script>");
cmd.Parameters.Add("@expression", strExpression);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, strExpression);')</script>");
cmd.Parameters.Add("@color", strColor);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, strColor);')</script>");
cmd.Parameters.Add("@ispublic", bIsPublic);
Response.Write("<script language='JavaScript'>alert('cmd.Parameters.Add(, bIsPublic);')</script>");
conn.Open();
Response.Write("<script language='JavaScript'>alert('conn.Open();')</script>");
cmd.ExecuteNonQuery();
Response.Write("<script language='JavaScript'>alert('cmd.ExecuteNonQuery();')</script>");
conn.Close();
Response.Write("<script language='JavaScript'>alert('conn.Close();')</script>");
}
写好后在VS浏览没有问题可是IIS发布以后就回出现ChatRoom未定义的网页错误并且执行不了ChatRoom.SendMsg(txtContent, user_to, textcolor, expression, isPublic);这句。希望给个解决的方法,,, --------------------编程问答-------------------- ChatRoom.SendMsg(txtContent, user_to, textcolor, expression, isPublic);
补充:.NET技术 , C#