• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 638
  • Last Modified:

Open and close modal popup based on conditions

This is what I need:

if (condition == A)
       
     {
                 Open popup with a Please Wait message and a Close button
                 while ((line = sr.ReadLine()) != null)   // This loop takes about 10 minutes
                     {
                           Do Stuff
                           if (condition == B)
                                  {
                                         Change message in popup to "Finished"
                                  }
                     }   // End While
       } // End if (condition == A)

How can this be done?

Thanks,
0
Dovberman
Asked:
Dovberman
4 Solutions
 
AndyAinscowCommented:
if (condition == A)
       
     {
                 Open popup with a Please Wait message and a Close button
//At this point your program will wait until a modal popup is closed
0
 
AndyAinscowCommented:
Typically you would put the long job into a thread
0
 
hjgodeCommented:
You have to show the popup in a separet thread. You can use the backgroundworker class to create a form in a background thread or you use your own new thread.

The backgroundworker calls provides members to call back into your main caode, so your main 'knows' that state (ie a progress or finish).

There are many examples out there, just search for "backgroundworker popup".

    public Form1()
    {
        InitializeComponent();

    }

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
       /* this.Invoke((Action)(() =>
                        {
                            var form2 = new Form2();
                            form2.Show();
                        }));  Winforms Method*/
         Dispatcher.Invoke((Action)(() =>
                        {
                            var form2 = new Form2();
                            form2.Show();
                        }));

    }

    private void Form1_Click(object sender, EventArgs e)
    {
        backgroundWorker1.RunWorkerAsync();
    }

Open in new window


In Form2 you would run your long file reading task.
0
 
SAMIR BHOGAYTAFreelancer and IT ConsultantCommented:
hi.. please go through this example

<styletype="text/css">
.noDisplay
{
display: none;
}
</style>

<divID="divModalPopup">
<cc1:ModalPopupExtenderID="ModalPopupExtender2"runat="server"
TargetControlID="dummy"
PopupControlID="Panel13"
BackgroundCssClass="modalBackground"
DropShadow="true"
OkControlID="OKButton">
</cc1:ModalPopupExtender>
<asp:LinkButtonrunat="server"ID="dummy"CssClass="noDisplay"Text="Click me..."/>
<asp:PanelID="Panel13"runat="server"CssClass="modalPopup"Style="display: none"Width="270px"BorderStyle="Double"ScrollBars="Auto">
<br/>
<tablestyle="width: 100%;"bgcolor="#79A9B9"cols="2"align="center"
cellpadding="2"cellspacing="2"border="2"bordercolor="olive">
<tr>
<tdalign="center">
<b>Attention User!</b>
</td>
</tr>
<tr>
<tdalign="center">
Your request has been submitted. Please make a note of the job information for your records.
</td>
</tr>
</table>
<br/>
<divalign="center">
<asp:ButtonID="OKButton"runat="server"Text="OK"/>
</div>
</asp:Panel>
<br/>
</div>
0
 
DovbermanAuthor Commented:
Thank you.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now