asp.net 等待3秒后跳转到其他页面,不用js,后台写就可以谢谢 a.aspx 后台操作完,输出===3秒后跳转到b.aspx代码在。cs中写就可以 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Response.Write( " <meta http-equiv= 'refresh ' content= '3;url=b.aspx '> "); 既然是回馈信息,肯定是前台跳转,那么必然用js或meta 直接用timer就OK了...或者js倒计时...或者<meta http-equiv="refresh" content="3;url=Index.aspx"> Thread.Sleep(3);timertjs都行! <meta http-equiv="refresh" content="3;url=Index.aspx">介样 <meta http-equiv="refresh" content="3;url=Index.aspx">timer计时器也行 只有js和meta可以做到。你要用c#写3秒后,那前台页面会一直空白的 在Button1_Click方法的最后加入一行:System.Threading.Thread.Sleep(3000); 就是玩的酷一点,就像CSDN的发帖后,会倒计时3秒钟,这个时候,前台不是空白,会输出内容“修改成功,3秒后返回b页面”用timer 怎么写呢? protected static void reulr() { Redirect("brand.aspx"); // 我这里写的不正确 } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(_connstring); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "update probrand set brandname=@brandname where brandid=@brandid "; cmd.Parameters.AddWithValue("@brandid",int.Parse(hidden1.Value)); cmd.Parameters.AddWithValue("@brandname", TextBox1.Text); using (con) { con.Open(); cmd.ExecuteNonQuery(); Label2.Text="品牌名已修改完!"; System.Threading.Thread.Sleep(1000); cmd.CommandText = "update procategory set brandname=@brandname where brandid=@brandid"; cmd.ExecuteNonQuery(); Label3.Text = "类别中的品牌名已修改完!"; System.Threading.Thread.Sleep(1000); cmd.CommandText = "update newpro set brandname=@brandname where brandid=@brandid"; // cmd.CommandText = "update newpro set brandname=@brandname where brandid=@brandid"; cmd.ExecuteNonQuery(); Label4.Text = "所有产品中的品牌名已修改完!"; System.Threading.Thread.Sleep(1000); reulr(); } 跳转函数ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert(\'登录成功!\');setTimeout(function(){location.href='b.aspx'},1000); </script>"); 3秒的话,将1000该成3000就可以了ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert(\'登录成功!\');setTimeout(function(){location.href='b.aspx'},3000); </script>");你不是加群了嘛,这样简单的问题群里人都可以回答的哦 Thread.Sleep(3);re...还是这个快速点 但是不科学 用了sleep 就不会显示输出的提示了 private string _connstring = WebConfigurationManager.ConnectionStrings["proconnectionstring"].ConnectionString; protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection(_connstring); SqlCommand cmd=new SqlCommand(); cmd.Connection=con; cmd.CommandText="select * from pro"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = con; cmd2.CommandText = "insert into newpro (protitle,prosummary,procontent,proimg,addtime,clickcount,pagetitle,pagekeywords,pagedescriptions)values(@protitle,@prosummary,@procontent,@proimg,@addtime,@clickcount,@pagetitle,@pagekeywords,@pagedescriptions)"; //SqlDataAdapter sda = new SqlDataAdapter(cmd); //DataSet dst = new DataSet(); con.Open(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { cmd2.Parameters.AddWithValue("@protitle", sdr["protitle"]); cmd2.Parameters.AddWithValue("@prosummary", sdr["prosummary"]); cmd2.Parameters.AddWithValue("@procontent", sdr["procontent"]); cmd2.Parameters.AddWithValue("@proimg", sdr["proimg"]); cmd2.Parameters.AddWithValue("@addtime", sdr["addtime"]); cmd2.Parameters.AddWithValue("@clickcount", sdr["clickcount"]); cmd2.Parameters.AddWithValue("@pagetitle",sdr["pagetitle"]); cmd2.Parameters.AddWithValue("@pagekeywords",sdr["pagekeywords"]); cmd2.Parameters.AddWithValue("@pagedescriptions",sdr["pagedescriptions"]); cmd2.ExecuteNonQuery(); } con.Close(); }请问错在哪里?行 31: while (sdr.Read())行 32: {行 33: cmd2.Parameters.AddWithValue("@protitle", sdr["protitle"]);行 34: cmd2.Parameters.AddWithValue("@prosummary", sdr["prosummary"]);行 35: cmd2.Parameters.AddWithValue("@procontent", sdr["procontent"]); 源文件: d:\Gdent999\admin\oldtonew.aspx.cs 行: 33 b/s通信是这样,B请求 S发送 ,3秒后B要重新请求S才能发送,3秒后怎么重新请求?代码都写在S端了,还请求个毛啊 Thead.Sleep的方式是不行的。这样页面一直不输出不返回。客户端一直空白。等你Thead.Sleep(3000)。 在这3秒内,前台页面一直空白,觉得这样有意思?只能用js或meta的。 我只是想要这样的效果,最好用c#写的,如果c#确定不行的话,js也可以,不过js我不会写啊 本帖最后由 net_lover 于 2011-04-10 14:14:48 编辑 也可以这样<script runat="server"> protected void Button1_Click(object sender, EventArgs e) { body.Attributes.Add("onload","setTimeout('window.location=\"b.aspx\"',3000)"); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body id="body" runat="server"> 本帖最后由 net_lover 于 2011-04-10 14:20:23 编辑 Response.Write( " <meta http-equiv= 'refresh ' content= '3;url=b.aspx '> ");我记得这个只能用于静态页面 html htm.. 在哪看的?aspx的结果就是html 高手来看看这个问题啊,在线等 委托与事件的关系,代码如下 IOCP服务端怎么怎么开发。 面试题 求一个正则表达式 atlas在.NET2003下能用吗? 按纽响应确认键 100分救急啊!!cookie购物车问题 如何将.cs文件生成.dll组件? 请教:有关DropDownList绑定的问题 能否写一个类似MVC的OnActionExecuting的方法,可以在每个方法开始和结束的时候调用 列名无效的问题
或者js倒计时...
或者
<meta http-equiv="refresh" content="3;url=Index.aspx">
timert
js
都行!
介样
用timer 怎么写呢?
protected static void reulr()
{
Redirect("brand.aspx");
// 我这里写的不正确
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(_connstring);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "update probrand set brandname=@brandname where brandid=@brandid ";
cmd.Parameters.AddWithValue("@brandid",int.Parse(hidden1.Value));
cmd.Parameters.AddWithValue("@brandname", TextBox1.Text);
using (con) {
con.Open();
cmd.ExecuteNonQuery();
Label2.Text="品牌名已修改完!"; System.Threading.Thread.Sleep(1000);
cmd.CommandText = "update procategory set brandname=@brandname where brandid=@brandid";
cmd.ExecuteNonQuery();
Label3.Text = "类别中的品牌名已修改完!";
System.Threading.Thread.Sleep(1000);
cmd.CommandText = "update newpro set brandname=@brandname where brandid=@brandid"; // cmd.CommandText = "update newpro set brandname=@brandname where brandid=@brandid";
cmd.ExecuteNonQuery();
Label4.Text = "所有产品中的品牌名已修改完!"; System.Threading.Thread.Sleep(1000);
reulr(); }
re...
还是这个快速点 但是不科学
protected void Page_Load(object sender, EventArgs e)
{ SqlConnection con = new SqlConnection(_connstring);
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandText="select * from pro"; SqlCommand cmd2 = new SqlCommand();
cmd2.Connection = con;
cmd2.CommandText = "insert into newpro (protitle,prosummary,procontent,proimg,addtime,clickcount,pagetitle,pagekeywords,pagedescriptions)values(@protitle,@prosummary,@procontent,@proimg,@addtime,@clickcount,@pagetitle,@pagekeywords,@pagedescriptions)";
//SqlDataAdapter sda = new SqlDataAdapter(cmd);
//DataSet dst = new DataSet();
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
cmd2.Parameters.AddWithValue("@protitle", sdr["protitle"]);
cmd2.Parameters.AddWithValue("@prosummary", sdr["prosummary"]);
cmd2.Parameters.AddWithValue("@procontent", sdr["procontent"]);
cmd2.Parameters.AddWithValue("@proimg", sdr["proimg"]);
cmd2.Parameters.AddWithValue("@addtime", sdr["addtime"]);
cmd2.Parameters.AddWithValue("@clickcount", sdr["clickcount"]);
cmd2.Parameters.AddWithValue("@pagetitle",sdr["pagetitle"]);
cmd2.Parameters.AddWithValue("@pagekeywords",sdr["pagekeywords"]);
cmd2.Parameters.AddWithValue("@pagedescriptions",sdr["pagedescriptions"]); cmd2.ExecuteNonQuery();
}
con.Close();
}请问错在哪里?行 31: while (sdr.Read())
行 32: {
行 33: cmd2.Parameters.AddWithValue("@protitle", sdr["protitle"]);
行 34: cmd2.Parameters.AddWithValue("@prosummary", sdr["prosummary"]);
行 35: cmd2.Parameters.AddWithValue("@procontent", sdr["procontent"]);
源文件: d:\Gdent999\admin\oldtonew.aspx.cs 行: 33
这样页面一直不输出不返回。客户端一直空白。
等你Thead.Sleep(3000)。 在这3秒内,前台页面一直空白,觉得这样有意思?只能用js或meta的。
<script runat="server"> protected void Button1_Click(object sender, EventArgs e)
{
body.Attributes.Add("onload","setTimeout('window.location=\"b.aspx\"',3000)");
}
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="body" runat="server">
Response.Write( " <meta http-equiv= 'refresh ' content= '3;url=b.aspx '> ");
我记得这个只能用于静态页面 html htm..
在哪看的?aspx的结果就是html