Solved

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

Posted on 2014-09-12
2
262 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
Comment Utility
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
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now