为什么AJAX在我的服务器上不起作用?请帮我!!! [英] Why AJAX doesn't work at my server ? Please help me!!!
本文介绍了为什么AJAX在我的服务器上不起作用?请帮我!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
当我在Visual Studio 2010中进行调试时,计时器刻度线可以正常工作,并且我的文本框是update,当我将自己的服务器放在xampp上时,我的页面无法正常工作
我的计时器未更新我的文本框((为什么?:(
页面代码:
Hi all,
when i do debug in visual studio 2010, timer tick work perfectly and my textbox is update , when I put in their own server on xampp my page don''t work fine
my timer is not update my textbox (( why? :(
Page code:
<pre lang="xml"><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Chating.aspx.cs" Inherits="Practica.Chating" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
height: 246px;
width: 327px;
}
.style2
{
overflow: auto;
}
.style3
{
height: 7px;
}
</style>
<script language="javascript">
function textBoxScroll() {
var objDiv = document.getElementById("AllChat");
objDiv.scrollTop = objDiv.scrollHeight;
}
</script>
</head>
<body onload ="textBoxScroll()">
<form id="form1" runat="server" class="style1">
<table border=2 bgcolor=gray align="left" class="style4">
<tr><td bgcolor=red class="style8"><asp:Label id="LabelName" runat="server"
type="text" class="style3" CssClass="style9"></asp:Label></td></tr>
<tr><td bgcolor=red class="style13">
<asp:TextBox id="AllChat" runat="server"
type="text" class="style15" TextMode="MultiLine" Height="172px"
Width="316px" ReadOnly="True" CssClass="style2"></asp:TextBox></td>
</tr>
<tr><td bgcolor=red class="style3"> <span class="style11">Message : </span>
<asp:TextBox id="myMessage" runat="server" type="text"
class="style3" Width="170px" CssClass="style10" Height="22px"></asp:TextBox>
<asp:Button ID="Button5" runat="server" Text="Send" Width="65px"
onclick="Button5_Click" />
</td></tr>
</table>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer runat="server" ID="timer1" Interval="8000" OnTick="timer1_Tick" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using BuissnesLogic;
namespace Practica
{
public partial class Chating : System.Web.UI.Page
{ Sql_Connect ob = new Sql_Connect();
private string userName;
protected void Page_Load(object sender, EventArgs e)
{
string msg = (string)Application["msg"];
AllChat.Text = msg;
string numele = ob.NumePrenume(Session["ID"].ToString())[0] + " " +
ob.NumePrenume(Session["ID"].ToString())[1];
LabelName.Text = numele;
userName = numele;
}
protected void Button5_Click(object sender, EventArgs e)
{
string name = userName ;
string message = myMessage.Text;
string my = name + " [say]:" + message;
Application["msg"] = Application["msg"] + my + Environment.NewLine;
AllChat.Text = Application["msg"].ToString();
myMessage.Text = "";
}
protected void timer1_Tick(object sender, EventArgs e)
{
AllChat.Text = Application["msg"].ToString();
}
}
}
可能是我需要配置我的apache服务器吗?
我使用.net Framework 3.5
请帮我!!!!
may be i need to config my apache server???
i use .net framework 3.5
Help me please!!!!
推荐答案
我缺少一个updatepanel.将文本框放在这样的更新面板中,以计时器作为触发器,然后重试.
I am missing an updatepanel. Put the textbox inside an updatepanel like this, with the timer as trigger and try again.
<asp:Timer ID="timer1" Interval="8000" runat="server">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox id="AllChat" runat="server"
type="text" class="style15" TextMode="MultiLine" Height="172px"
Width="316px" ReadOnly="True" CssClass="style2"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
我在Apache服务器上找到了适用于工作Ajax的solutino!
要使ASP.NET 2.0中的AJAX在您的APACHE优秀网站上运行,只需在网站根文件夹中创建2个空文件:
WebResource.axd
ScriptResource.axd
I found solutino for work Ajax on Apache server!!!
To make AJAX in ASP.NET 2.0 working on your great APACHE websites, just create 2 empty files in website root folder:
WebResource.axd
ScriptResource.axd
这篇关于为什么AJAX在我的服务器上不起作用?请帮我!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文