JCWEBHOST
asked on
asp messagebox
Hey guys, i need to show a message box in my web app when hosted?
i have this c# code
now it just shows the ok button, i need it to show yes or no and if the user selects no it just close and if the user selects yes and want to code in c# to do a redirect and pass parameter, which i want to code in c#.
Please help...
i have this c# code
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("alert('{0}');", message);
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", sScript, true);
}
now it just shows the ok button, i need it to show yes or no and if the user selects no it just close and if the user selects yes and want to code in c# to do a redirect and pass parameter, which i want to code in c#.
Please help...
ASKER
ok how can i code so when the user clicks the yes or no button?
Check this
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("confirm('{0}');", message);
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", sScript, true);
}
ASKER
that works and display the yes and no, is they way when the user clicks yes that i can code in c# for that button or javascript?
ASKER
i need to code in c#
Yes you can do that
sScript = String.Format("if(confirm( '{0}')) { alert('Code goes here if user click on YES');} else {alert('Code goes here if user click on NO/CANCEL');}", message);
sScript = String.Format("if(confirm(
ASKER
this code fine:
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("confirm('{0 }');", message);
ScriptManager.RegisterStar tupScript( this, this.GetType(), "alert", sScript, true);
}
now in c# code how do i code if the user click on yes or no?
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("confirm('{0
ScriptManager.RegisterStar
}
now in c# code how do i code if the user click on yes or no?
ASKER
can i have i redirect to a page if yes?
sScript = String.Format("if(confirm( '{0}')) { alert('Code goes here if user click on YES');} else {alert('Code goes here if user click on NO/CANCEL');}", message);
sScript = String.Format("if(confirm(
You can not do this. You need write the code in javascript as I mentioned above
Yes you can redirect
sScript = String.Format("if(confirm( '{0}')) { window.location='your_page .aspx';} else {alert('Code goes here if user click on NO/CANCEL');}", message);
sScript = String.Format("if(confirm(
ASKER
ok how can i do a redirct in java when the user clicks the yes button?
ASKER
and if the user select no nothing must happen
ASKER
got an erorr:
rror: Sys.WebForms.PageRequestMa nagerServe rErrorExce ption: Input string was not in a correct format.
rror: Sys.WebForms.PageRequestMa
Show your showMessageBox function
ASKER
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("if(confirm( '{0}')) { window.location='/login/ho me.aspx';} else {}", message);
ScriptManager.RegisterStar tupScript( this, this.GetType(), "alert", sScript, true);
}
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("if(confirm(
ScriptManager.RegisterStar
}
Try below code. I am just checking the error you are getting is bocoz of "/' and then let me know
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("if(confirm( '{0}')) { window.location='home.aspx ';} else {}", message);
ScriptManager.RegisterStar tupScript( this, this.GetType(), "alert", sScript, true);
}
protected void showMessageBox(string message)
{
string sScript;
message = message.Replace("'", "");
sScript = String.Format("if(confirm(
ScriptManager.RegisterStar
}
ASKER
still erorr :(
ASKER
erorr here
sScript = String.Format("if(confirm( '{0}')) { window.location='home.aspx ';} else {}", message);
sScript = String.Format("if(confirm(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HTH
Ivo Stoykov
Open in new window