Javascript Pop Up in ASP.NET

I want to a confirm popup box using javascript in my asp.net page using Page.RegisterClientScriptBlock (or similiar) . Here is how I want it to work.

when the user click "submit" button, it should check that selectedindex on one of the dropdown is > 0. If so show a confirm pop up. If Ok is pressed continue with the next step and if cancel is pressed return. It would be nice if the javascript checks for the selectedindex of drop down rather then doing it via the code. I want all this done in the code behind and not on the html side of the form.
Thanks in advance.

I have foudn it easier to put a <asp:Litertal> control in the <head> section of a page and then just write the Literal's text as the javascript function

HTH
-M3mph15

0

pratikshahseAuthor Commented: 2009-05-07

Mohan,

Your reply is what I was looking for. I have one question though.
you have alert boxes when the user clicks yes or no. Instead I want to continue with the application when user clicks ok and return when user clicks cancel. Is that something we can do from the script itself or is there a way where i can get the value of the button pressed in the code and depending upon what value i get i decide what to do.

Also I am trying to do line breaks in my message by using \r\n and it does not allow me to do that . infact the script fails and I do not see the pop up box. It would be great if you can let me know how to fix that too.

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

next line of code is
facility = ddlFacility.SelectedValue;
opportunity = ddlOpportunity.SelectedValue;
cycle = ddlCycle.SelectedValue;
then it goees ahead and updates the database and all the other stuff. this all should be done if 'ok' is pressed.

if 'cancel' is pressed, just exit out of that function and take back to the page when the pop up was initiated.

Sorry for asking too many questions but I am pretty new with javascripts and have never worked with them before.