日期:2014-05-18  浏览次数:20415 次

2.0 AJAX 求一刷新页面的代码(C#)
一个页面,需要定时刷新。系统只要有新订单来就要有个喇叭在闪,新手,在线求教

------解决方案--------------------
不知道楼主需要什么样的?


function loadcookies()
{
document.getElementById( 'divname ').innerHTML= "会 员 名: <font color= 'red '> " + cookies_nameconent + " </font> ";
var type;
if(cookies_typeconent == 0)
{
type = "个人会员 ";
}
else if(cookies_typeconent == 1)
{
type = "企业会员 ";
}
document.getElementById( 'divtype ').innerHTML= "会员类别: <font color= 'red '> " + type + " </font> ";
document.getElementById( 'divmail ').innerHTML= "站内邮件: <font color= 'red '> 获取中… </font> [ <a href= 'person/Mailbox.aspx '> 查看 </a> ] ";
left.IsValidMailBox(cookies_idconent,is_backcall);
}
function is_backcall(res)
{
var mail = document.getElementById( 'divmail ');
var bRet = res.value;
if(bRet == 0)
{
mail.innerHTML= "站内邮件: <font color= 'red '> 无新邮件 </font> [ <a href= 'Mailbox.aspx '> 查看 </a> ] ";
}
else if(bRet == 200)
{
mail.innerHTML= "站内邮件: <a onclick= 'loadcookies(); ' alt= '点此重新获取 ' style= 'cursor:hand '> <font color= 'red '> 获取失败 </font> </a> [ <a href= 'person/Mailbox.aspx '> 查看 </a> ] ";
}
else
{
mail.innerHTML= "站内邮件: <font color= 'red '> "+bRet+ "封未读 </font> [ <a href= 'person/Mailbox.aspx '> 查看 </a> ] ";
document.getElementById( 'sound ').innerHTML = " <embed src= 'images/system.wav ' width= '0 ' height= '0 ' border= '0 ' autostart= 'true ' loop= 'false '> </embed> ";
}
setTimeout( "loadcookies() ",10000);
}



left.cs

/// <summary>
/// 获取新邮件
/// </summary>
/// <param name= "userid "> </param>
/// <returns> </returns>
[AjaxPro.AjaxMethod()]
public int IsValidMailBox(string userid)
{
DataSQLServer.SQLComboBoxSelect sql = new DataSQLServer.SQLComboBoxSelect();
int flag = 0;
flag = sql.BuildSelect_Count( "job_mailbox ", "User_id ", Convert.ToInt32(userid), "job_mailbox_num ",0);
return flag;
}