Solved

I need to a javascript or another web popup box that works like a windows message box

Posted on 2014-09-12
2
265 Views
Last Modified: 2014-10-09
I need a way to display popup box much like a windows message box that when a submit button is clicked it checks if a textbox contians certian words. If the textboxes does then a popup box comes up asking the user if they want to continue the operation or return back to the webpage.
Below is the code that I have worked out if I could use a windows message box, I know that you can't use a windows box in a web applicaion. However, below is how I would like for the popup box to work.
if (txtWebinarCourseName.Text.Contains("Servicing") || txtWebinarCourseName.Text.Contains("Your Book") || txtWebinarCourseName.Text.Contains("Advanced")
                                 || txtWebinarCourseName.Text.Contains("Billing") || txtWebinarCourseName.Text.Contains("EA/EFS") || txtWebinarCourseName.Text.Contains("The EA/EFS Partnership")
                                 || txtWebinarCourseName.Text.Contains("Compliance") || txtWebinarCourseName.Text.Contains("IS Appeals")
                                 || txtWebinarCourseName.Text.Contains("Who to Contact") || txtWebinarCourseName.Text.Contains("My Work Items")
                                 || txtWebinarCourseName.Text.Contains("Quote-Requote Process") || txtWebinarCourseName.Text.Contains("New Customer")
                                 || txtWebinarCourseName.Text.Contains("On-Boarding") || txtWebinarCourseName.Text.Contains("Allstate Claims")
                                 || txtWebinarCourseName.Text.Contains("Property Re-inspection Initiative ") || txtWebinarCourseName.Text.Contains("Reports and Compensation")
                                 || txtWebinarCourseName.Text.Contains("Know Your Numbers") || txtWebinarCourseName.Text.Contains("Risk Management")
                                 || txtWebinarCourseName.Text.Contains("West Central"))
                            {
                                string messageBoxText = "The course name you entered is simular to an exsisting course: " + txtWebinarCourseName.Text + "Do you want to continue?";
                                string caption = "Verify Course Name";
                                MessageBoxButtons button = MessageBoxButtons.YesNo;
                                MessageBoxIcon icon = MessageBoxIcon.Question;

                                // Display message box
                                DialogResult result = MessageBox.Show(messageBoxText, caption, button, icon);

                                // Process message box results 
                                switch (result)
                                {
                                    case DialogResult.Yes:
                                        // User pressed Yes button 
                                        SubmitWebinar(false);
                                        break;
                                    case DialogResult.No:
                                        // User pressed No button 
                                        break;
                                }

Open in new window

0
Comment
Question by:newjeep19
  • 2
2 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40320360
basically you block the execution of any code in a page using a message box (alert, confirm,prompt)
all block the execution of the code until the user clock ok or cancel if available

the other box available you can find don't work like that, they use a callback function executed when the user click on a button.

so we have :

 // Display message box
                                DialogResult result = MessageBox.Show(messageBoxText, caption, button, icon, callbackFunction);

with somewhere you declare :
function callbackFunction(result) {
                                // Process message box results 
                                switch (result)
                                {
                                    case DialogResult.Yes:
                                        // User pressed Yes button 
                                        SubmitWebinar(false);
                                        break;
                                    case DialogResult.No:
                                        // User pressed No button 
                                        break;
                                }
}

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40320368
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now