Pause Loop until click modal button
<p>I need enter manually some values during a loop for. I'm using C# ASP.Net with WebForms.</p>

<p>I'm trying this:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace systemII
{
    public partial class MY_System : System.Web.UI.Page
    {
        private List&lt;String&gt; List = new List&lt;string&gt;();
        private bool loop = false;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            while (loop) { }

            for (int i = 1; i &lt;= 10; i++)
            {
                string a = "A" + i.ToString();
                if (i == 4 || i == 5)
                {
                    loop = true;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                }
                else
                {
                    List.Add(a);
                }
            }
        }

        protected void Button2_Click(object sender, EventArgs e) // modal button
        {
            string b = "BB";
            Lista.Add(b);
            loop = false;
            return;
        }
    }
}
</code></pre>

<p>But the Modal appear on screen after end of loop. I need pause the loop until I enter the textbox value.</p>

<p>Any can help me? Sorry for my bad english.</p>