Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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 :&nbsp; </span>
    <asp:TextBox id="myMessage"    runat="server" type="text"
        class="style3" Width="170px" CssClass="style10" Height="22px"></asp:TextBox>&nbsp;
    <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>





C#
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();
        }
    }
}


may be i need to config my apache server???

i use .net framework 3.5

Help me please!!!!
Posted

I am missing an updatepanel. Put the textbox inside an updatepanel like this, with the timer as trigger and try again.

HTML
<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>
 
Share this answer
 
v4
Comments
He6cTeP 30-Jun-11 14:03pm    
Hi Ruard, not work :( textbox not update :(
and in the browser show this error :

unable to load client infrastructure asp.net ajax
"Sys" - definition is absence
:(

problem 100% in the my server because when i debug my site in visual that work perfektly and wen i put this in my server not work and browser get error!!!
[no name] 30-Jun-11 15:21pm    
Add a tag 'Apache' and give some information about your server (like apache version, Operating System).
He6cTeP 30-Jun-11 15:37pm    
My server : Apache Friends XAMPP (Basis Package) version 1.7.3
Apache 2.2.14
My OS : Windows XP sp3
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900