title: Label text not updating when SEND button is pressed - ASP.NET
body: <p>I have contact us page where I am sending mail when SEND button is pressed, everything works fine but button wasnt disabled at the end of the code, and label text was not updated to reflect change. I am entirely sure what label is not updated as code executes just fine.</p>
  <p>This is master page:</p>
  <pre><code>&lt;%@ Master Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;MIMO.master.cs&quot; Inherits=&quot;MIMO_WEB_R02.MIMO&quot; %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head runat=&quot;server&quot;&gt;
      &lt;link href=&quot;WebStyle.css&quot; rel=&quot;stylesheet&quot; /&gt;
      &lt;script src=&quot;Scripts/jquery-3.5.1.min.js&quot;&gt;&lt;/script&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;asp:ContentPlaceHolder ID=&quot;head&quot; runat=&quot;server&quot;&gt;
      &lt;/asp:ContentPlaceHolder&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
  &lt;Div id =&quot;Navbar&quot;&gt;
      &lt;img class=&quot;logo&quot; src=&quot;Images/LOGO%20MIMO%20V1.png&quot; /&gt;
              &lt;ul class=&quot;Menu&quot;&gt;
              &lt;li&gt;&lt;a href=&quot;About.aspx&quot;&gt;ABOUT&lt;/a&gt;&lt;/li&gt;
              &lt;li class=&quot;dropdown&quot;&gt;&lt;a href=&quot;javascript:void(0)&quot; class=&quot;dropbtn&quot;&gt;SERVICES&lt;/a&gt;
              &lt;div class=&quot;dropdown-content&quot;&gt;
              
                  &lt;asp:LinkButton id=&quot;D1&quot; runat=&quot;server&quot; OnClick=&quot;Unnamed_Click&quot; Text=&quot;MAINTENANCE &amp; PLANNING&quot;&gt;&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton class=&quot;link&quot; runat=&quot;server&quot; OnClick=&quot;Unnamed_Click&quot;&gt;TESTING &amp; VERIFICATION&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton class=&quot;link&quot; runat=&quot;server&quot; OnClick=&quot;Unnamed_Click&quot;&gt;AUDITS &amp; INSPECTION&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton class=&quot;link&quot; runat=&quot;server&quot;&gt;UNCERTAINTY CALCULATIONS&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton class=&quot;link&quot; runat=&quot;server&quot;&gt;MIS-MEASUREMENTS&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton class=&quot;link&quot; runat=&quot;server&quot;&gt;VBA DEVELOPMENT&lt;/asp:LinkButton&gt;
  
              &lt;/div&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;Calculations.aspx&quot;&gt;CALCULATIONS&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;Contact.aspx&quot;&gt;CONTACT US&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
              &lt;/Div&gt;
              &lt;div id =&quot;Image-Content&quot;&gt;
                  &lt;img Class=&quot;IGM&quot; src=&quot;Images/TwoRig-CRP.jpg&quot; /&gt;
                  &lt;/div&gt;
              &lt;div id =&quot;Link-Content&quot;&gt;
  
                   &lt;asp:HyperLink ID=&quot;L1&quot; runat=&quot;server&quot; Text=&quot;LINK1&quot;&gt;&lt;/asp:HyperLink&gt;&lt;p&gt; to &lt;/p&gt;
                  &lt;asp:HyperLink ID=&quot;L2&quot; runat=&quot;server&quot; Text=&quot;LINK2&quot;&gt;&lt;/asp:HyperLink&gt;
                  &lt;/div&gt;
          
              &lt;asp:ContentPlaceHolder ID=&quot;Body&quot; runat=&quot;server&quot;&gt;
              &lt;/asp:ContentPlaceHolder&gt;
              &lt;div id =&quot;Footer&quot;&gt;&lt;h5&gt;address goes here&lt;/h5&gt;&lt;/div&gt;
          
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>This child page</p>
  <pre><code>&lt;%@ Page Title=&quot;&quot; Language=&quot;C#&quot; MasterPageFile=&quot;~/MIMO.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Contact.aspx.cs&quot; Inherits=&quot;MIMO_WEB_R02.ContactUs&quot; %&gt;
  
  &lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;head&quot; runat=&quot;server&quot;&gt;
      &lt;script src=&quot;JsValidation.js&quot;&gt;&lt;/script&gt;
      &lt;style type=&quot;text/css&quot;&gt;
          .auto-style1 {
              width: 181px;
          }
      &lt;/style&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;Body&quot; runat=&quot;server&quot;&gt;
  
       &lt;div class =&quot;Page_Content&quot;&gt;
       &lt;h3&gt;CONTACT US&lt;/h3&gt;
       &lt;p&gt;Thanks for visiting our website for any information get in touch&lt;/p&gt;
              
      &lt;fieldset style=&quot;Width:40%&quot;&gt;
          &lt;Legend&gt;Contact Us&lt;/legend&gt;&lt;table id=&quot;ContactDetails&quot;&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Name&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderName&quot; Placeholder=&quot;Name&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
        &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;NameID&quot; ControlToValidate=&quot;SenderName&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Name is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Surname&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderSurname&quot; Placeholder=&quot;Surname&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;SurnameID&quot; ControlToValidate=&quot;SenderSurname&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Last Name is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Title&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderTitle&quot; Placeholder=&quot;Title&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;TitleVal&quot; ControlToValidate=&quot;SenderTitle&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Title is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;
           &lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Company&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderCompany&quot; Placeholder=&quot;Company&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;CompanyID&quot; ControlToValidate=&quot;SenderCompany&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Company Name is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Email&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderEmail&quot; Placeholder=&quot;Email&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;EmailID&quot; ControlToValidate=&quot;SenderEmail&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Email is required&quot; ForeColor=&quot;Red&quot; Display=&quot;Dynamic&quot; Font-Size=&quot;Small&quot;&gt;
        &lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Telephone (Optional)&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderTelephone&quot; Placeholder=&quot;Telephone&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;TelephoneID&quot; ControlToValidate=&quot;SenderTelephone&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Telephone is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;
        &lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Subject&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;SenderSubject&quot; Placeholder=&quot;Subject&quot; runat=&quot;server&quot; Width=&quot;200px&quot;/&gt;&lt;/td&gt;
           &lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;SubjectID&quot; ControlToValidate=&quot;SenderSubject&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Subject is required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;
        &lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;tr&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;Message Body&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:TextBox ID=&quot;TxtComments&quot; Placeholder=&quot;Email&quot; runat=&quot;server&quot; TextMode=&quot;MultiLine&quot; CssClass=&quot;MultiLineTextBox&quot; Width=&quot;200px&quot; Height=&quot;87px&quot;/&gt;
           &lt;/td&gt;&lt;td style=&quot;vertical-align:top&quot;&gt;&lt;asp:RequiredFieldValidator ID=&quot;Comments&quot; ControlToValidate=&quot;TxtComments&quot; ValidationGroup=&quot;groupName&quot; runat=&quot;server&quot; ErrorMessage=&quot;Comments are required&quot; ForeColor=&quot;Red&quot; Font-Size=&quot;Small&quot;&gt;
        &lt;/asp:RequiredFieldValidator&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td class=&quot;auto-style1&quot;&gt;&lt;asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; OnClientClick=&quot;ClientSideClick(this);&quot; Text=&quot;SEND&quot; Width=&quot;78px&quot; OnClick=&quot;Button1_Click&quot;/&gt;
           &lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan=&quot;3&quot;&gt;&lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Text=&quot;This is some label text here&quot;&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;/tr&gt;    
       &lt;/table&gt;
          
        &lt;/fieldset&gt;
       &lt;/div&gt;
    
  &lt;/asp:Content&gt;
  </code></pre>
  <p>This C# server code</p>
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
      {
          String[] ParamToPass = new String[9];
          String ConnectionString = &quot;DESKTOP-9V04GKP&quot;;
          try
          {
          ParamToPass[0] = DateTime.Now.ToString(&quot;yyyy-MM-dd HH:mm:ss&quot;);
          ParamToPass[1] = SenderName.Text;
          ParamToPass[2] = SenderSurname.Text;
          ParamToPass[3] = SenderTitle.Text;
          ParamToPass[4] = SenderCompany.Text;
          ParamToPass[5] = SenderEmail.Text;
          ParamToPass[6] = SenderTelephone.Text;
          ParamToPass[7] = SenderSubject.Text;
          ParamToPass[8] = TxtComments.Text;
  
              //MailAddress to = new MailAddress(&quot;mail1&quot;);
              //MailAddress from = new MailAddress(&quot;mail2&quot;);
  
              //MailMessage message = new MailMessage(from, to);
              //message.Subject = SenderSubject.Text.ToString();
              //message.Body = TxtComments.Text.ToString();
  
              //SmtpClient client = new SmtpClient(&quot;smtp.gmail.com&quot;, 587)
              //{
              //    Credentials = new NetworkCredential(&quot;credentials go here&quot;),
              //    EnableSsl = true
  
              //};
              //// code in brackets above needed if authentication required
  
  
              //client.Send(message);
  
              Label1.Text = &quot;Thank you for your message we will get back at you as soon as possible&quot;;
              Button1.Enabled = false;
              SQL_Insert(ConnectionString, ParamToPass); 
          }
          catch (SmtpException ex)
          {
              Label1.Text = &quot;We are experiencing technical difficulty please come back at another time&quot;;
              Button1.Enabled = true;
          }
          
      }
  </code></pre>