How to stop the function when message box popping out?

60 Views Asked by At

I loop a list to do checking when false will pop out a message to show update or delete. However the message box after looping only pop out. How to pop out immediately when meet the condition?

My coding like this:

                foreach (var checkDist in distinctList)   //loop the record
                {
                    if (tbl == null)
                    {
                        string insertRst = TodoInsert();
                    }
                    else
                    {
                        string message = "CompanyNo: " + Dcompany + " with Location: " + Dloc + " found in database. Do You want to overwrite?";
                        ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "Msg", "confirm('" + message +"')", true);

                        string confirmValue = Request.Form["confirmValue"];
                        if (confirmValue == "Yes")
                        {
                            string value = "YES";
                        }
                        else
                        {
                            string value = "NO";
                        }
                    }
                }
0

There are 0 best solutions below