title: Thank You message display after form submission mvc umbraco
body: <p>I have created a Contact us form using surface controller in umbraco.
  Form is working fine.
  Now i need to display a thank you message after form submission using java script. i am quite weak in java scipt please guide me how i can do it. I am pasting the code that i have implemented.</p>
  
  <p>My ActionResult</p>
  
  <pre><code>public ActionResult Contact(ContactUs model)
      {
          if (ModelState.IsValid)
          {
              var sb = new StringBuilder();
              sb.Append("&lt;table&gt;");
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Name&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.Name));
              sb.Append("&lt;/tr&gt;");
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Company&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.Company));
              sb.Append("&lt;/tr&gt;");
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Email&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.EmailFrom));
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Phone&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.Tel));
              sb.Append("&lt;/tr&gt;");
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Interested&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.Intrested));
              sb.Append("&lt;/tr&gt;");
              sb.Append("&lt;tr&gt;");
              sb.Append("&lt;td&gt;Message&lt;/td&gt;");
              sb.Append(string.Format("&lt;td&gt;{0}&lt;/td&gt;", model.Message));
              sb.Append("&lt;/tr&gt;");
              String subject = String.Format("{0} wants to talk to you!", model.Name, model.EmailFrom, model.Company);
              string emailTo = Umbraco.Field("toEmail").ToString();
  
              SmtpClient smtpServer = new SmtpClient();
              smtpServer.Host = Umbraco.Field("host").ToString();
  
              string ssl = Umbraco.Field("ssl").ToString();
              smtpServer.EnableSsl = Convert.ToBoolean(ssl);
              //smtpServer.EnableSsl = true;
              //smtpServer.Host = "119.159.253.203";
              //smtpServer.Credentials = new System.Net.NetworkCredential("raheemjanjua28@gmail.com", "code-desk");
              System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential();
              Credentials.UserName = Umbraco.Field("fromEmailAddress").ToString();
              Credentials.Password = Umbraco.Field("password").ToString();
  
              smtpServer.UseDefaultCredentials = false;
              smtpServer.Credentials = Credentials;
              string portNumber = Umbraco.Field("portNumber").ToString();
              smtpServer.Port = int.Parse(portNumber);
  
              MailMessage mail = new MailMessage();
              mail.From = new MailAddress(model.EmailFrom);
              mail.To.Add(emailTo);
              //mail.To.Add("ammar.zaheer@code-desk.com");
              mail.Subject = subject;
              mail.IsBodyHtml = true;
              mail.Body = sb.ToString();
              if (model.Attachment != null &amp;&amp; model.Attachment.ContentLength &gt; 0)
              {
                  var attachment = new Attachment(model.Attachment.InputStream, model.Attachment.FileName);
                  mail.Attachments.Add(attachment);
              }
              smtpServer.Send(mail);
  
              return CurrentUmbracoPage();
          }
  
          else
          {
  
              return CurrentUmbracoPage();
          }
      }
  </code></pre>
  
  <p>and this my view</p>
  
  <pre><code>   &lt;div id="respond" class="comment-respond"&gt;
    @model Umbraco.AddingValues.Web.Model.ContactUs
  
     @using (Html.BeginUmbracoForm("Contact", "ContactUsSurface", FormMethod.Post, new { @class = "contact-form" }))
   { 
  @Html.ValidationSummary(true)
  
  &lt;div id="form"&gt;
      &lt;div class="comment-form-author"&gt;
      @Html.LabelFor(x =&gt; x.Name)
      @Html.TextBoxFor(x =&gt; x.Name)
      @Html.ValidationMessageFor(x =&gt; x.Name)
       &lt;/div&gt;
       &lt;div class="comment-form-author"&gt;
       @Html.LabelFor(x =&gt; x.Company)
      @Html.TextBoxFor(x =&gt; x.Company)
      @Html.ValidationMessageFor(x =&gt; x.Company)
        &lt;/div&gt;
        &lt;div class="comment-form-email"&gt;
      @Html.LabelFor(x =&gt; x.EmailFrom, "Email")
      @Html.TextBoxFor(x =&gt; x.EmailFrom)
      @Html.ValidationMessageFor(x =&gt; x.EmailFrom,"Please enter a valid Email Address")
        &lt;/div&gt;
       &lt;div class="comment-form-author"&gt;
      @Html.LabelFor(x =&gt; x.Tel)
      @Html.TextBoxFor(x =&gt; x.Tel)
      @Html.ValidationMessageFor(x =&gt; x.Tel)
           &lt;/div&gt;
         &lt;div class="comment-form-url"&gt;
      @Html.LabelFor(x =&gt; x.Intrested)
      @Html.TextBoxFor(x =&gt; x.Intrested)
      @Html.ValidationMessageFor(x =&gt; x.Intrested)
        &lt;/div&gt;
       &lt;div class="comment-form-comment"&gt;
      @Html.LabelFor(x =&gt; x.Message)
      @Html.TextAreaFor(x =&gt; x.Message)
      @Html.ValidationMessageFor(x =&gt; x.Message)
         &lt;/div&gt;
  
  &lt;/div&gt;
   &lt;div id ="hidden_div" style="display: none"&gt;
      &lt;h3&gt;Thank You&lt;/h3&gt;
  &lt;/div&gt;
   &lt;div class="forms-button"&gt;
  &lt;input id="submit" class="button" name="submit" type="submit" value="Submit" onsubmit="alert('thank you')" /&gt;
       &lt;div class="fileUpload "&gt;
              &lt;span&gt;Upload&lt;/span&gt;
             @* &lt;input type="file" class="upload" /&gt;*@
           &lt;input type="file" name="attachment" id="attachment" class="upload" value ="Upload"/&gt; 
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>}</p>
  
  <p>
  This is the java script code i am implementing</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
    function showHide() {
  
      var div = document.getElementById("hidden_div");
      if (div.style.display == 'none') {
          div.style.display = '';
      }
      else {
          div.style.display = 'none';
      }
  }
  </code></pre>
  
  <p></p>