How to use AjaxToolKit Confirm Button Extender?
<p>In my ASP.NET web-based application, I have a normal ASP.NET button that has a method behind it for sending emails as following:</p>

<p><strong>ASP.NET Code:</strong></p>

<pre><code>&lt;asp:Button ID="btnSendReminders" runat="server" Text="Send Reminders" OnClick="btnSendReminders_Click"  /&gt;
</code></pre>

<p><strong>Code-Behind:</strong></p>

<pre><code>protected void btnSendReminders_Click(object sender, EventArgs e)
        {
            SendEmailTOAllUser();
        }


        protected void SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)
        {
            SmtpClient sc = new SmtpClient("MAIL.Aramco.com");
            try
            {
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress("pssp@aramco.com", "PMOD Safety Services Portal (PSSP)");

                // In case the mail system doesn't like no to recipients. This could be removed
                //msg.To.Add("pssp@aramco.com");

                msg.Bcc.Add(toAddresses);
                msg.Subject = MailSubject;
                msg.Body = MessageBody;
                msg.IsBodyHtml = isBodyHtml;
                sc.Send(msg);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        protected void SendEmailTOAllUser()
        {
            string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspForTest;Integrated Security=True";

            using (SqlConnection conn = new SqlConnection(connString))
            {
                var sbEmailAddresses = new System.Text.StringBuilder(2000);
                string quizid = "";

                // Open DB connection.
                conn.Open();

                string cmdText = "SELECT MAX (QuizID) As mQuizID FROM dbo.QUIZ WHERE IsSent &lt;&gt; 0";
                using (SqlCommand cmd = new SqlCommand(cmdText, conn))
                {
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            // There is only 1 column, so just retrieve it using the ordinal position
                            quizid = reader["mQuizID"].ToString();

                        }
                    }
                    reader.Close();
                }

                string cmdText2 = @"SELECT e.Username, d.DivisionShortcut
                                FROM
                                  employee e
                                  join Divisions d on (e.DivisionCode = d.SapCode)
                                  left join 
                                    (select A.QuizID, a.Username 
                                     from UserQuiz a join 
                                     (select max(QuizID) QuizID from dbo.Quiz where IsSent=1) b
                                     on a.QuizId = b.QuizID
                                     ) c
                                   on e.Username = c.Username
                                 WHERE c.QuizID is null
                                 Order By d.DivisionShortcut";
                using (SqlCommand cmd = new SqlCommand(cmdText2, conn))
                {
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            var sName = reader.GetString(0);
                            if (!string.IsNullOrEmpty(sName))
                            {
                                if (sbEmailAddresses.Length != 0)
                                {
                                    sbEmailAddresses.Append(",");
                                }
                                // Just use the ordinal position for the user name since there is only 1 column
                                sbEmailAddresses.Append(sName).Append("@aramco.com");
                            }
                        }
                    }
                    reader.Close();


                    // Add the parameter to the command
                    var oParameter = cmd.Parameters.Add("@QuizID", SqlDbType.Int);


                    var sEMailAddresses = sbEmailAddresses.ToString();
                    string link = "&lt;a href='http://pmv/pssp/StartQuiz.aspx?testid=" + quizid + "'&gt; Click here to participate &lt;/a&gt;";
                    string body = @"&lt;font color='red' size='18pt'&gt;&lt;b&gt; ***REMINDER*** &lt;/b&gt;&lt;/font&gt; &lt;br /&gt;&lt;br /&gt; 
                                Good day, &lt;br /&gt;&lt;br /&gt;
                                &lt;b&gt;This is just a gentle reminder asking you to participate in the last new short safety quiz &lt;/b&gt;"
                                    + link +
                                    @"&lt;br /&gt;&lt;br /&gt;
                                Also, give yourself a chance to gain more safety culture by reading the PMOD Newsletter.
                                &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
                                PLEASE &lt;span class='highlight'&gt;IGNORE&lt;/span&gt; THIS MESSAGE IF YOU HAVE ALREADY PARTICIPATED IN THIS QUIZ.
                                &lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;
                                This email was generated using the &lt;a href='http://pmv/pssp/Default.aspx'&gt;PMOD Safety Services Portal (PSSP) &lt;/a&gt;. 
                                Please do not reply to this email.";

                    int sendCount = 0;
                    List&lt;string&gt; addressList = new List&lt;string&gt;(sEMailAddresses.Split(','));
                    StringBuilder addressesToSend = new StringBuilder();

                    for (int userIndex = 0; userIndex &lt; addressList.Count; userIndex++)
                    {
                        sendCount++;
                        if (addressesToSend.Length &gt; 0)
                            addressesToSend.Append(",");

                        addressesToSend.Append(addressList[userIndex]);
                        if (sendCount == 10 || userIndex == addressList.Count - 1)
                        {
                            SendEmail(addressesToSend.ToString(), "", "REMINDER: Notification of New Weekly Safety Quiz", body, true);
                            addressesToSend.Clear();
                            sendCount = 0;
                        }
                    }


                    // Update the parameter for the current quiz
                    oParameter.Value = quizid;
                    // And execute the command
                    cmd.ExecuteNonQuery();

                }
                conn.Close();
            }
        }
</code></pre>

<p>Now, instead of using <code>&lt;asp:Button&gt;</code>, I want to use:</p>

<pre><code> &lt;ajaxToolkit:ConfirmButtonExtender ID="btnSendReminders" runat="server" TargetControlID="btnSendReminders"
                                                ConfirmText="Are you sure you want to click this?"
                                                OnClientCancel="CancelClick" /&gt;
</code></pre>

<p>to have a ConfirmMessage. But I don't know why I got the following error:
**</p>

<blockquote>
  <p>Extender control 'btnSendReminders' cannot extend 'btnSendReminders'.
  Extender controls of type 'AjaxControlToolkit.ConfirmButtonExtender'
  cannot extend controls of type
  'AjaxControlToolkit.ConfirmButtonExtender'.</p>
</blockquote>

<p>And I don't know why. So how can I use it instead of the <code>&lt;asp:button&gt;</code>?</p>

<p><strong>UPDATE:</strong></p>

<p>I just figured out how to use it. I should use it as following:</p>

<pre><code>&lt;asp:Button ID="btnSendReminders" runat="server" Text="Send Reminders" OnClick="btnSendReminders_Click"  /&gt;
            &lt;ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnSendReminders"
                                                ConfirmText="Are you sure you want to send reminders to these employees?"
                                                OnClientCancel="CancelClick"&gt;
                                                &lt;/ajaxToolkit:ConfirmButtonExtender&gt;
</code></pre>

<p>But the problem now is when the confirm message appears, and click on the Cancel button, still the page will be refreshed and the reminders will be sent. <strong>How to prevent that in case of clicking the Cancel button?</strong> </p>
