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

注册成功,页面10秒后跳转...跳转主界面!欢迎此用户!
主要想完成一个功能是.用户注册成功.右放提示...正在转入主界面 并且10秒后跳转...


别告诉我这个类似的:<meta http-equiv="refresh" content="10;URL=./login.aspx">

因为这个是定时间跳转,如果我打开注册界面.还没注册,10秒到了那不是也跳转了么???对伐...

下面是本人的!能在点击注册,立即跳转到登陆界面...但是没达到10秒等待的功能,也没达到自动传值的功能.谢谢大家了.
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
strcn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
cn = new SqlConnection(strcn);

if(Request.UrlReferrer!=null)
{
String url = Request.UrlReferrer.ToString();
ViewState["url"]=url;
}
}
------------------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
string In_uid = this.User_id.Text;
string In_name = this.User_name.Text;
string In_pwd = this.User_password.Text;
string In_pwdd = this.User_passwordd.Text;
string In_email = this.User_email.Text;
string StrSql = "select * from operator where uid = '"+In_uid+"'";
string Stremail = "select * from operator where email='"+In_email+"'";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(StrSql,cn);
da.Fill(ds,"aa");

da.SelectCommand.CommandText=Stremail;
da.Fill(ds,"email");

if(ds.Tables["aa"].Rows.Count>1)
{
this.Label1.Text="已经有此用户!";
}
else if(ds.Tables["email"].Rows.Count>1)
{
this.Label1.Text="此邮箱已经被人注册!";
}
else
{
this.Label1.Text="";
string SQL = "insert into operator(uid,name,pwd,pwdd,email) values('"+In_uid+"','"+In_name+"','"+In_pwd+"','"+In_pwdd+"','"+In_email+"')";

SqlCommand cmd = new SqlCommand(SQL,cn);
cn.Open();

try
{
cmd.ExecuteNonQuery();
this.Label1.Text="注册成功!";

string url=""; 
if(ViewState["url"]!=null)
{
url=ViewState["url"].ToString();
if(url.IndexOf("./login.aspx")<0)
{
url="./login.aspx";//将待转跳的页面设为你的首页 

}
else

url="./login.aspx";//将待转跳的页面设为你的首页 

Response.Redirect(url);//跳转 
}
catch(SqlException)
{
this.Label1.Text="注册失败!";
Label1.Style["color"]="red";
}
}

}

------解决方案--------------------
JScript code

 <script type="text/javascript">
  var wait = 10000;
  window.setTimeout("timer()", wait);
  function timer()
  { 
    window.location.href='=login.aspx'"
  }
                                
 </script>