在警告框中单击“确定”后,需要重定向到另一个“aspx”页面。 [英] Need to redirect to another 'aspx' page after clicking 'OK' in alert box.

查看:58
本文介绍了在警告框中单击“确定”后,需要重定向到另一个“aspx”页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在客户端点击我在javascript写了这个函数



功能确认()
{
< span class =code-keyword> var confirm_value = document.createElement( INPUT);
confirm_value.type = hidden;
confirm_value.name = confirm_value;

if (确认( 您确定要更改密码吗?如果密码更改成功,您将被重定向到主登录页面&您必须使用新密码登录))
{
confirm_value。 value = ;
}
其他
{
confirm_value。 value = ;
}

document.forms [ 0 ]。appendChild(confirm_value);
}



因此,如果在确认框中单击确定,则客户端点击如果密码更改成功,则进入C#中的代码区域。

  string  confirmvalue = Request.Form [   confirm_value]; 
if (confirmvalue ==
{

this .Page.ClientScript.RegisterStartupScript( .GetType(), alert if(alert('密码已成功更改。使用新密码登录') true );
lblmsg.Visible = true ; // 不需要这个
lblmsg.Text =( 密码更改成功 ); // 不需要这个
Response.Redirect( 默认值。 ASPX);
}
其他
{
.Page .ClientScript.RegisterStartupScript( this .GetType(), 警告 警告('有问题,而你点击否') true );
}



如果我在代码中没有写''response.redirect(default.aspx)''这就产生了警告框

但我无法重定向到主登录页面



我的意思是我们无法看到警告框(其中包含''passwrd change is successful''消息) if response.redirect(default.aspx);是写的



帮我告诉我哪里出错!

解决方案

我想你是在下面的行中缺少。



  .Page.ClientScript.RegisterStartupScript ( this  .GetType(),  alert  alert('密码已成功更改。使用新密码登录')); 
lblmsg.Visible = true ; // 不需要这个
lblmsg.Text =( 密码已成功更改); // 不需要此
Response.Redirect( default.aspx);


替换包含''的代码警报框''带有以下内容给了我解决方案。



 ClientScript.RegisterStartupScript(Page.GetType(),  alert  alert('密码已成功更改。使用新密码登录'); window.location ='default.aspx'; true ); 


on client click i wrote this function in javascript

function confirmation()
{
var confirm_value=document.createElement("INPUT");
confirm_value.type="hidden";
confirm_value.name="confirm_value";

if(confirm("Are You sure You want to change the password?If password change is successful you will be redirected to main login page & You must login with New Password"))
{
confirm_value.value="Yes";
}
else
{
confirm_value.value="No";
}

document.forms[0].appendChild(confirm_value);
}


so on client click if ''ok'' is clicked in confirmation box & if password change is successful it is entering the code area in C#

string confirmvalue = Request.Form["confirm_value"];
if (confirmvalue == "Yes")
{

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "if(alert('Password Changed Succesfully.Login with New Password')", true);
lblmsg.Visible = true;                            //dont need this
lblmsg.Text = ("Password Changed Succesfully");   //dont need this
Response.Redirect("default.aspx");
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Some Problem is there & You clicked No')", true);
}


this is generating alertbox if i dont write ''response.redirect("default.aspx")'' in the code
but i m unable to redirect to main login page

I mean we are unable to see alert box(which contains ''passwrd change is succesful'' message) if response.redirect("default.aspx"); is written

Help to get me know where i m going wrong!!

解决方案

I think you are missing in below line.

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Password Changed Succesfully.Login with New Password')", true);
lblmsg.Visible = true;                            //dont need this
lblmsg.Text = ("Password Changed Succesfully");   //dont need this
Response.Redirect("default.aspx");


Replacing the code containing ''alert box'' with the following gave me the solution.

ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Password Changed Succesfully.Login with New Password');window.location='default.aspx';", true);


这篇关于在警告框中单击“确定”后,需要重定向到另一个“aspx”页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆