[RESOLVED]Popup for Process

Hi,

I want to show popup box for process until the process is done from server.

Example: adding product from admin , so until process done i want to show popup on the middle of the page and user cannot click until process done.

Please, I need your suggestions and logic to achieve my scenario.

Appreciate for your Quick and Better response.

Hi smd_yasin,
Based on your post, you want to show a box as a processbar, and user cannot click until process done. If I understand correctly, you’d better to try my code as below.

<head runat="server">
    <title></title>
    <style type="text/css">
    .lblTxtCenter
         {
              text-align: center;
         }
    </style>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
    <script type="text/javascript">
        //$(document).ready(function ()
        //{
        //    $("#Button1").click(function ()
        //    {
        //        $("#Button1").attr({ "Enable": "false" });
        //    })
        //})// this JQuery is used to disable Button1 until process done
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="pro">
         <asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="False">
             <ContentTemplate>
                 <div style='width: 200px; background-color: Silver; height: 20px;'>
                     <asp:Label runat="server" ID="lbl" CssClass="lblTxtCenter"></asp:Label></div>
                 <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" Enabled="false">
                 </asp:Timer>
                 <br/>
             </ContentTemplate>
         </asp:UpdatePanel>
        </div>
         <asp:Button ID="Button1" runat="server" Text="Start" OnClick="Button1_Click" />
    </div>
    </form>
</body>
 protected void Button1_Click(object sender, EventArgs e)
        {
           UpdatePanel1.Visible = true;
           ThreadClass cl = new ThreadClass();
           cl.begin();
           Timer1.Enabled = true;
        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {
          if (ThreadClass.present <= 100)
          {
             Button1.Enabled = false;//if you use JQuery function above ,you may annotate it
             lbl.Text = ThreadClass.present.ToString() + "%";
             lbl.BackColor = System.Drawing.Color.Red;
             lbl.Width = ThreadClass.present * 2;
          }
          if (ThreadClass.present == 100)
          {
             ThreadClass.present = 0;
             UpdatePanel1.Visible = false;
             Button1.Enabled = true;
             Timer1.Enabled = false;
          }
        }
        public class ThreadClass
        {
            public static int present;
            public ThreadClass(){}
            public void begin()
            {
               if (present == 0)
               {
                   lock (this)
                   {
                      Thread tr = new Thread(new ThreadStart(() =>
                         {
                           for (int i = 0; i <= 1000; i++)
                           {
                              present = 100 * i / 1000;//Calculate the percentage completed  
                              Thread.Sleep(10);
                           }
                         }));
                   tr.IsBackground = true;
                   tr.Start();
                   }
               }
            }
        }

If you have any concern about it, please feel free to let me know.
Best regards,
Aswecan

Hi Aswecan,

I’m very thankful, that you posted proper script.

Leave a Reply