javascript confirm box in C#

G

Guest

Hi,
I want to add a JavaScript confirmation box on a DropDown. I want to display
the confirmation box only when a particular value is selected. I check this
condition in selectedindexchanged event as below. As shown I try both
"Response.Write" and
"Page.RegisterStartUpScript" but the control always goes past the javascript
to the next statement irrespective of whether I select "OK" or "Cancel" in
the confirm box.

Please help



if (ddlPeriodStage.SelectedValue =="Close")
{
//1. POPUP
string scriptString = "<script language='JavaScript'> ";
scriptString += "confirm ('Are you sure you want to Close this period.')";
scriptString += "</script>";
Response.Write(scriptString)
//Page.RegisterStartupScript("ClientScript", scriptString);
Response.Write("hello");

}

Thanks
Manika
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top