0

i would like to display a preloading image like spinning circle,please wait text etc on button click and show an alert message when the function complete. In my scenario on button click a code behind method is called for sending email. when sending email i would like to display preloader and when completes an alert message should be displayed. Following is my code.

protected void btnSubmit1_Click(object sender, EventArgs e)
{
    const string esender = "emailid@email.com";
    const string sp = "password";
    string bodyMessage = "";
    //string text = txtmsg.text;
    try
    {
        SmtpClient smtp = new SmtpClient
        {
            Host = "smtp.gmail.com",
            Port = 587,
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            Credentials = new System.Net.NetworkCredential(esender, sp),
            Timeout = 30000
        };
        bodyMessage = "Details of the sender\n" +
            "Name : " + txtName.Text + "\n\n" +
            "Email : " + txtemail.Text + "\n\n" +
            "Contact : " + txtNumber.Text + "\n\n" +
            "Subject : " + txtsubject.Text + "\n\n" +
            "Message : " + txtmsg.Text;
        MailMessage message = new MailMessage(esender, "receiver@gmail.com","Customer Enquiry", bodyMessage);
        smtp.Send(message);
    }
    catch (Exception ex)
    {

    }
}

and aspx code for button

<asp:Button ID="btnSubmit1" Text="Submit Message" class="btn btn-primary btn-lg"  OnClick="btnSubmit1_Click" runat="server" />
MethodMan
  • 18,625
  • 6
  • 34
  • 52
abdulkhadar7
  • 125
  • 1
  • 1
  • 12
  • Are you familiar with `UpDatePanels` http://stackoverflow.com/questions/7704171/asp-net-display-loading-message-while-update-panel-is-updating – MethodMan Apr 28 '16 at 20:11
  • Yeah, I used but not good with threading.Any suggestion – abdulkhadar7 Apr 28 '16 at 20:12
  • this has nothing to do with Threading take a look at the link it's pretty straight forward here is another link - http://www.dotnetcurry.com/ShowArticle.aspx?ID=227 if you are not sure then do some google searching.. the MessageDlg part should be the easiest.. don't just post code and expect others to complete it for you when you don't even show any effort of trying something yourself in regards to the spinning / progress notification – MethodMan Apr 28 '16 at 20:16

0 Answers0