Click here to Skip to main content
15,886,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
on client click i wrote this function in javascript

C#
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#
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!!
Posted
Updated 1-Mar-13 23:15pm
v3
Comments
bbirajdar 2-Mar-13 4:00am    
When the page redirects, the alert message will not be seen. So change the flow.
Nandakishore G N 2-Mar-13 6:32am    
instead of alert use confirm.You'll get another option for staying in the same page or redirect to next page

I think you are missing in below line.

C#
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");
 
Share this answer
 
Comments
sri67 2-Mar-13 6:14am    
@sanjayK.Gupta: Sir,where & What am I missing? I should be redirected to 'default.aspx' after that alert 'popup' is displayed.
Sanjay K. Gupta 2-Mar-13 6:48am    
You have added an extra 'if' before 'alert'.
Replacing the code containing 'alert box' with the following gave me the solution.

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900