初次尝试接触ajax,结果是一头雾水。发现ajax并不是真正异步。后台执行的时候updatepanel并不会刷新。
我要实现的功能是:在导入数据页面中显示进度提示和进度条。
于是尝试使用Ext的进度条。//后台代码
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 20; i++)
{
System.Threading.Thread.Sleep(2000);
//传递进度和当前状态
Session["lev"] = i.ToString(); //不行
Response.Write("<script>document.getElementById('TextBox1').value=" + i + "</script>");//不行
TextBox1.Text = i.ToString();//也不行
}
}//前台代码 function show()
{
//ext进度条对话框
Ext.MessageBox.show({
title: 'Please wait',
msg: 'Loading items...',
progressText: 'Initializing...',
width:300,
progress:true,
closable:false,
animEl: 'Button1'
});
// 进度控制
var f=function(v){
return function(){
if(v == 12){
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Your fake items were loaded!');
}else{
var i = v/11;
Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
}
};
}; //定时监听
var listen=function ()
{
return function() {
var cc="<%=getCurr() %>";
var aa='<%=Session["lev"].ToString()%>';
var bb=getCookie('current');
var tep=document.getElementById('TextBox1').value;
alert(aa+tep+bb+cc);
setTimeout(f(current), 500);
//alert(current); //以上方法都无法获取进度值
}; };
window.setInterval(listen(), 1000); //1秒监听一次
} 我也尝试用timer控件定时对updatepanel更新,不过在执行后台代码时timer并不响应。我是新手,大家见笑了。。
望高手指点!!!!!
我要实现的功能是:在导入数据页面中显示进度提示和进度条。
于是尝试使用Ext的进度条。//后台代码
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 20; i++)
{
System.Threading.Thread.Sleep(2000);
//传递进度和当前状态
Session["lev"] = i.ToString(); //不行
Response.Write("<script>document.getElementById('TextBox1').value=" + i + "</script>");//不行
TextBox1.Text = i.ToString();//也不行
}
}//前台代码 function show()
{
//ext进度条对话框
Ext.MessageBox.show({
title: 'Please wait',
msg: 'Loading items...',
progressText: 'Initializing...',
width:300,
progress:true,
closable:false,
animEl: 'Button1'
});
// 进度控制
var f=function(v){
return function(){
if(v == 12){
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Your fake items were loaded!');
}else{
var i = v/11;
Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
}
};
}; //定时监听
var listen=function ()
{
return function() {
var cc="<%=getCurr() %>";
var aa='<%=Session["lev"].ToString()%>';
var bb=getCookie('current');
var tep=document.getElementById('TextBox1').value;
alert(aa+tep+bb+cc);
setTimeout(f(current), 500);
//alert(current); //以上方法都无法获取进度值
}; };
window.setInterval(listen(), 1000); //1秒监听一次
} 我也尝试用timer控件定时对updatepanel更新,不过在执行后台代码时timer并不响应。我是新手,大家见笑了。。
望高手指点!!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货