View Single Post
  #1 (permalink)  
Old July 17th, 2017, 08:25 AM
JackBlack99 JackBlack99 is offline
Registered User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2017
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 11 Animating the Contact Form

Hi,

I have copied the code for this Try It Out section but I do not see any animation after the message has been sent. As I am unable to see where the problem is in my code I was hoping that someone could help?

My code files are as follows:

ContactForm.ascx.cs

<code>
...
protected void btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
string mailBody = System.IO.File.ReadAllText(fileName);

mailBody = mailBody.Replace("##Name##", txtName.Text);
mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text);
mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text);
mailBody = mailBody.Replace("##BusinessPhone##", txtBusinessPhone.Text);
mailBody = mailBody.Replace("##Comments##", txtComments.Text);

try
{
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response from web site";
myMessage.Body = mailBody;

myMessage.From = new MailAddress(AppConfiguration.FromAddress, AppConfiguration.FromName);
myMessage.To.Add(new MailAddress(AppConfiguration.ToAddress, AppConfiguration.ToName));

SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);

lblMessage.Visible = true;
MessageSentPara.Visible = true;
FormTable.Visible = false;
//System.Threading.Thread.Sleep(5000);
}
catch (SmtpException)
{
lblMessage.Text = "An error occurred while sending your e-mail. Please try again.";
}
finally
{
lblMessage.Visible = true;
}
}
}

</code>

ContactForm.asx:

<code>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
<div id="TableWrapper">
<table class="auto-style1" runat="server" id="FormTable">
...
</table>
</div>

<asp:Label ID="lblMessage" runat="server" Text="Message Sent" Visible="false"></asp:Label>
<p runat="server" id="MessageSentPara" visible="False">Thank you for your message.
We'll get in touch with you if necessary.</p></ContentTemplate>
</asp:UpdatePanel>
...


</asp:UpdateProgress>
<script type="text/javascript">
$(function () {
$('form').bind('submit', function () {
if (Page_IsValid) {
$('#TableWrapper').slideUp(3000);
}
});
});
function pageLoad()
{
$('.Attention').animate({ width: '600px' }, 3000)
.animate({ width: '100px' }, 3000)
.fadeOut('slow');
}
</script>

</code>

_reference.js:

<code>
/// <reference path="jquery-3.1.1.js" />
</code>
Reply With Quote