我的服务器是windows sever 2008+IIS7+Oracle 10g的64位机器。
页面要实现的功能是一个label每秒刷新一次 显示时间。
技术用的是AJAX的timer和UpdatePanel结果在本机调试好使,在服务器上调试也好使,但是登陆服务器的网站,进入这个页面就不显示时间,也不刷新。
我本机装的是vs2008+windowsXP+Oracle10g客户端 32位机器。
谁能帮我解答。
页面要实现的功能是一个label每秒刷新一次 显示时间。
技术用的是AJAX的timer和UpdatePanel结果在本机调试好使,在服务器上调试也好使,但是登陆服务器的网站,进入这个页面就不显示时间,也不刷新。
我本机装的是vs2008+windowsXP+Oracle10g客户端 32位机器。
谁能帮我解答。
解决方案 »
- 在 Windows7中文旗舰版下安装Visual Studio 2010中文旗舰版出错
- json绑定select option元素IE获取值概率问题
- GridView导出大量数据时出错,报该页无法显示了
- tab分页效果
- 如何让一个ASPX窗体在加载或者设计时自己设置大小,是否全屏等参数
- 明明装了sql server2000了 为什么还提示没装SQL SERVER2000或MSDE啊?
- 没分了,大家帮下忙吧``困饶了很久了
- 100分啊!帮帮我!立即给分!着急!
- 请从在ASPX页面继承System.Web.UI.Page中间继承一个类,中间类为何产生错误?
- 各位高手请帮忙!谁解决了这个问题我就叫位MM以身相许。。。
- N2CMS
- 请教如何实现这个功能 最方便的方法 是否有此类控件
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer2" runat="server" Interval="1001" OnTick="Timer2_Tick">
</asp:Timer>
<%--<asp:Timer ID="Timer1" runat="server" Interval="900" OnTick="Timer1_Tick">
</asp:Timer>--%>
<div>
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server" Height="400px" Width="490px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer2" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="490px" Height="90px" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><asp:Label ID="Label8"
runat="server" Text="Label"></asp:Label> 
<asp:Label ID="Label7" runat="server" Text="Label" Visible="False"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer2" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
 <asp:Button ID="Button1" runat="server" Text="发送" Width="90px" OnClick="Button1_Click" />
<asp:Button ID="Button4" runat="server" Text="关闭对话框" Width="90px" OnClick="Button4_Click" />
 <asp:Button ID="Button3"
runat="server" Text="打开消息记录" OnClick="Button3_Click" Width="90px" />  <asp:Button
ID="Button5" runat="server" Text="关闭消息记录" OnClick="Button5_Click" Width="90px" />
</td>
</tr>
<tr>
<td>
<asp:GridView ID="MSG_Record" runat="server" Height="400px" Width="490px" AllowPaging="True"
OnPageIndexChanging="MSG_Record_PageIndexChanging" Visible="False">
<Columns>
<asp:BoundField DataField="TIME" HeaderText="消息发送时间" ReadOnly="True" />
<asp:BoundField DataField="U_NAME" HeaderText="消息发送者" ReadOnly="True" />
<asp:BoundField DataField="FRIEND_NAME" HeaderText="消息接收者" ReadOnly="True" />
<asp:BoundField DataField="MESSAGE_CONTENT" HeaderText="消息内容" ReadOnly="True" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
sendmsg.aspx.cs:
public partial class SendMSG : System.Web.UI.Page
{
private static int last_ID;
private static int lid1;
//private DataSet dt;
private string u_id;
private string friend_id;
private string u_name1;
private string u_name2;
private static string org_id;
//private string userIP;
//private HttpCookie cookie;
/// <summary>
/// 页面载入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
//userIP = Request.UserHostAddress;
//cookie = Request.Cookies["info+"+userIP+""];
if (Request.QueryString["fid"] != null && Request.QueryString["fname"] != null)
{
friend_id = Request.QueryString["fid"].ToString();
u_name2 = ImLoginBLL.getuser1(friend_id).REAL_NAME;
Label8.Text = "与"+u_name2+"对话中!";
System.Web.HttpContext.Current.Session["FRIEND_ID_A"] = friend_id;
}
last_ID = GetLastID();
if (!IsPostBack)
{
u_id = Session["U_ID"].ToString();//@@
u_name1 = Session["REAL_NAME"].ToString();//@@ //u_name1 = cookie.Values["u_name+" + userIP + ""];
//u_id = cookie.Values["u_id+" + userIP + ""];
org_id = Session["org_id"].ToString();
Label2.Text = u_name1;
}
bind();
}
/// <summary>
/// gridview 数据绑定
/// </summary>
protected void bind()
{
u_id = Session["U_ID"].ToString();//@@
u_name1 = Session["REAL_NAME"].ToString();//@@
MSG_Record.DataSource = SendMSG_BLL.GetListMessage(u_id, friend_id);
MSG_Record.DataBind();
}
/// <summary>
/// gridview 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void MSG_Record_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
MSG_Record.PageIndex = e.NewPageIndex;
bind();//分页时要重新绑定
}
/// <summary>
/// 获取最新消息的ID
/// </summary>
/// <returns></returns>
private int GetLastID()
{
try
{
u_id = Session["U_ID"].ToString();//@@
u_name1 = Session["REAL_NAME"].ToString();//@@
//u_id = cookie.Values["u_id+" + userIP + ""];
return last_ID= Convert.ToInt32(SendMSG_BLL.GetNewMessage(friend_id,u_id).MSG_ID);
}
catch
{
ListBox1.Items.Add("对不起,现在没有新消息!");//
return -1;
}
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
//u_id = cookie.Values["u_id+" + userIP + ""];
//u_name1 = cookie.Values["u_name+" + userIP + ""]; u_id = Session["U_ID"].ToString();//@@
u_name1 = Session["REAL_NAME"].ToString();//@@ if (TextBox1.Text == "")
{
Label7.Text = "对不起,不能发送空消息!请重新输入!";
Label7.Visible = true;
}
else
{
Label7.Visible = false;
IM_Model_MSG model = new IM_Model_MSG();
model.TIME = DateTime.Now;
model.MESSAGE_CONTENT = TextBox1.Text;
model.IM_U_ID = u_id;
model.U_NAME = u_name1;
model.FRIEND_ID = friend_id;
model.FRIEND_NAME = u_name2;
model.ORG_ID = org_id;
model.TRANS_DOC_RECOD = "";
model.ISREAD = "0"; string time = DateTime.Now.ToString();
SendMSG_BLL.AddMessage(model); ListBox1.Items.Add(time + " " + model.U_NAME+":");
string[] attr = model.MESSAGE_CONTENT.ToString().Split('\n');
foreach (string i in attr)
{
ListBox1.Items.Add(i.ToString());
}
TextBox1.Text = "";
}
}
/// <summary>
/// 判断是否有新消息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Timer2_Tick(object sender, EventArgs e)
{
//HttpCookie cookie = Request.Cookies["info"];
//u_name1 = cookie.Values["u_name"];
//u_id = cookie.Values["u_id"];
last_ID = GetLastID();
//dt = null;
if ((lid1 < last_ID)&&(lid1!=-1)&&(last_ID!=-1))
{
//Timer1.Enabled = true;
IM_Model_MSG model = new IM_Model_MSG();
//u_id = cookie.Values["u_id+" + userIP + ""];
//u_name1 = cookie.Values["u_name+" + userIP + ""]; u_id = Session["U_ID"].ToString();//@@
u_name1 = Session["REAL_NAME"].ToString();//@@ model = SendMSG_BLL.GetNewMessage(friend_id, u_id);
ListBox1.Items.Add(model.TIME + " " + model.U_NAME + ":"); string[] attr = model.MESSAGE_CONTENT.ToString().Split('\n');
foreach (string i in attr)
{
ListBox1.Items.Add(i.ToString());
}
lid1 = last_ID;
SendMSG_BLL.msg_isread(lid1);
}
else
{
//ListBox1.Items.Add("对不起,现在没有新消息!");
}
Label3.Text = DateTime.Now.ToString();
}
}