p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Professional ASP.NET 4.5 : in C# and VB (http://p2p.wrox.com/book-professional-asp-net-4-5-c-vb-736/)
-   -   Ch 11 Animating the Contact Form (http://p2p.wrox.com/book-professional-asp-net-4-5-c-vb/99576-ch-11-animating-contact-form.html)

JackBlack99 July 17th, 2017 08:25 AM

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>

JackBlack99 July 18th, 2017 12:06 PM

I found the problem. I had not included the CssClass attribute in the label control. It is working now!


All times are GMT -4. The time now is 05:18 AM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.