Hi everyone,

Using c# Ive made a contact form user control in visual studio which i have put into an umbraco driven website. It is all in and working which means the user can fill out the form and an email confirmation is sent. Now the problem I'm having is that the text boxes and successful message is not clearing and displaying respectively. Here's my code (with dummy text) and was wondering if someone could help me and see why im getting this problem

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Mail;
using System.Net;

public partial class Controls_ContactControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void SendMail()
{
var fromAddress = "website@example.co.uk";
var toAddress = "example2@.co.uk";
const string toPassword = "1234";
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.example.com";
smtp.Port = ***;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(toAddress, toPassword);
smtp.Timeout = 20000;
}
smtp.Send(fromAddress, toAddress, subject, body);
}

protected void Button1_Click(object sender, EventArgs e)
{
try
{
SendMail();

if (IsPostBack)
{
lblMsgSend.Text = "Thank you, your message was sent successfully.";
lblMsgSend.Visible = true;
YourSubject.Text = "";
YourEmail.Text = "";
YourName.Text = "";
Comments.Text = "";
}
else
{
lblMsgSend.Text = "Sorry, there seemed to be an error. Please try again";
}

}
catch (Exception) { }
}
}

Thanks in advance