I have a form for clients to fill out, so I decided to make it an digital form. I have three pages subscriber_details, Package_Selection and Bank_Details. When the user has filled in all fields in the first and clicks next the page progresses onto the next till all three has been filled, when all three is filled they direct to a final page where all their details are presented to them for one last time, so that they can make sure its correct... on my subscriber_details.aspx I have the following code to store their details into sessions
protected void btnNext_Click(object sender, EventArgs e)
{
Session["FullName"] = txtFullName.Text;
if (txtCompanyName.Text == String.Empty)
Session["CompanyName"] = "N/A";
else
Session["CompanyName"] = txtCompanyName.Text;
if (txtVAT.Text == String.Empty)
Session["VAT"] = "N/A";
else
Session["VAT"] = txtVAT.Text;
Session["ContactNumber"] = txtContactNumber.Text;
if (txtFax.Text == String.Empty)
Session["Fax"] = "N/A";
else
Session["Fax"] = txtFax.Text;
if (txtDistrict.Text == String.Empty)
Session["District"] = "N/A";
else
Session["District"] = txtDistrict.Text;
Session["City"] = txtCity.Text;
Session["Street"] = txtStreet.Text;
Session["Code"] = txtPostal.Text;
if (txtTrading.Text == String.Empty)
Session["Trading"] = "N/A";
else
Session["Trading"] = txtTrading.Text;
Session["ID"] = txtID.Text;
Session["ContactPerson"] = txtContactPerson.Text;
if (txtEmail.Text == String.Empty)
Session["Email"] = "N/A";
else
Session["Email"] = txtEmail.Text;
}
then on my final.aspx I have the following code to use the sessions and replace the text in labels
protected void Page_Load(object sender, EventArgs e)
{
lblFullName.Text = Session["FullName"].ToString();
lblCompanyName.Text = Session["CompanyName"].ToString();
lblVat.Text = Session["VAT"].ToString();
lblContactNumber.Text = Session["ContactNumber"].ToString();
lblFax.Text = Session["Fax"].ToString();
lblDistrict.Text = Session["District"].ToString();
lblStreet.Text = Session["Street"].ToString();
lblCity.Text = Session["City"].ToString();
lblCode.Text = Session["Code"].ToString();
lblTrading.Text = Session["Trading"].ToString();
lblID.Text = Session["ID"].ToString();
lblContactPerson.Text = Session["ContactPerson"].ToString();
lblMail.Text = Session["Email"].ToString();
}
for some reason I get an "Object reference error", is it because my final.aspx page isn't my next page, because I have to pass through my package.aspx and bank_details.aspx first?
I have required field validators on the sessions that doesn't have an if statement, so the text wont be empty
You are not setting all of the Session variables. For example, you have not set Session["Email"] so the call to lblMail.Text = Session["Email"].ToString(); will throw the exception.
You should populate all Session variables you want to use and also check they are not null before doing .ToString(). This should catch it more gracefully.
Related
I'm new to coding so be nice. I'm trying to open a .ini file in a program, but I keep getting this error when I do so.
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
My code:
private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog o1 = new OpenFileDialog();
o1.Filter = "INI File |*.ini";
if (o1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
INIFile ini = new INIFile(o1.FileName);
string reini = ini.Read ("Profile Settings", "User ID");
int i = int.Parse(reini);
textBox1.Text = i.ToString();
textBox3.Text = i.ToString();
textBox4.Text = i.ToString();
textBox5.Text = i.ToString();
string rechini = ini.Read("Startup", "Check");
if(rechini == "checked")
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
}
}
}
}
Then the int i = int.parse(reini); gets marked in green
User ID is most probably an alphanumeric string. You'd be safer with .TryParse() in case user ID can be both of alphanumeric and integer types.
int i = -1;
string user_id = string.Empty;
if (!int.TryParse(reini, out i))
{
user_id = reini;
}
if (!String.IsNullOrEmpty(user_id)) // it is an alphanumeric
{
}
else // it is an integer, use i
{
}
UPDATE
Since your User ID is a string, just go with a string:
private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog o1 = new OpenFileDialog();
o1.Filter = "INI File |*.ini";
if (o1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
INIFile ini = new INIFile(o1.FileName);
string user_id = ini.Read ("Profile Settings", "User ID");
textBox1.Text = user_id;
textBox3.Text = user_id;
textBox4.Text = user_id;
textBox5.Text = user_id;
string rechini = ini.Read("Startup", "Add To Startup");
if(rechini == "checked")
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
}
}
}
}
UPDATE2
There is no Check key in your Startup INI file section. The code above is updated. There is Add To Startup, I guess you need this one.
As stribizhev said, in these cases, TryParse is better than Parse.
This is especially true as your User ID is a string of characters - not a number.
Also, 'Startup' 'checked' will always fail because the setting is named 'Add To Startup' (unless you will have another setting named 'checked' that is not in the file you supplied).
So, change to:
private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog o1 = new OpenFileDialog();
o1.Filter = "INI File |*.ini";
if (o1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
INIFile ini = new INIFile(o1.FileName);
string reini = ini.Read("Profile Settings", "User ID");
textBox1.Text = reini;
textBox3.Text = reini;
textBox4.Text = reini;
textBox5.Text = reini;
string rechini = ini.Read("Startup", "Add To Startup");
checkBox1.Checked = rechini == "checked";
}
}
My code is working fine if the statement (numtickets > tickav) is true (if tickets available is greater than tickets ordered) But if other wise, it throws in this error "FormatException was unhandled by user code, Input string was not in a correct format" on int numTick = Convert.ToInt32(txtNumberOfTickets.Text);
I do know that somehow I can use tryparse, i need help putting it in the code.
Any help would be appreciated, thank you
namespace TicketsApp
{
public partial class TicketOrder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["description"] != null && Session["EventID"] != null && Session["numtickets"] != null && Session["ticketcost"] != null
&& Session["State"] != null && Session["Section"] != null && Session["Row"] != null && Session["date"] != null)
{
if (!IsPostBack)
{
try
{
txtEventDescription.Text = Session["description"].ToString();
txtEventID.Text = Session["EventID"].ToString();
txtTicketsAvailable.Text = Session["numtickets"].ToString();
txtTicketCost.Text = Session["ticketcost"].ToString();
txtState.Text = Session["State"].ToString();
txtSectionNumber.Text = Session["Section"].ToString();
txtRowNumber.Text = Session["Row"].ToString();
txtNumberOfTickets.Focus();
lblOutput.Visible = false;
}
catch
{
lblError.Text = "Please Search for Tickets First!";
lblError.Visible = true;
btnOrderTickets.Visible = false;
Response.Redirect("TicketSearch.aspx");
return;
}
}
}
}
protected void btnOrderTickets_Click(object sender, EventArgs e)
{
TicketsDataAccessDataContext NewOrder = new TicketsDataAccessDataContext();
int numTick = Convert.ToInt32(txtNumberOfTickets.Text);
string s = txtTotalCost.Text.Substring(1);
int totc = Convert.ToInt32(s);
int id = Convert.ToInt32(txtEventID.Text);
DateTime dt = Convert.ToDateTime(Session["date"]);
int returnedValue = NewOrder.PlaceOrderFull(id, txtEventDescription.Text, dt, Session["State"].ToString(), Session["section"].ToString(), Session["Row"].ToString(), numTick, totc, "vfateev");
if (returnedValue != 0)
{
lblOutput.Text = "Error has occured. Please try again";
lblOutput.Visible = true;
btnOrderTickets.Visible = false;
}
else
{
lblOutput.Visible = true;
lblOutput.Text = "Thank you";
btnOrderTickets.Visible = false;
}
}
protected void txtNumberOfTickets_TextChanged1(object sender, EventArgs e)
{
int cos = Convert.ToInt32(txtTicketCost.Text);
int numtickets = Convert.ToInt32(txtNumberOfTickets.Text);
int tickav = Convert.ToInt32(txtTicketsAvailable.Text);
if (numtickets > tickav)
{
lblError.Text = "Please Enter a valid ticket quantity";
lblError.Visible = true;
lblOutput.Text = "";
txtNumberOfTickets.Text = "";
}
else
{
int cost = cos * numtickets + 5;
txtTotalCost.Text = "$" + cost.ToString();
lblOutput.Visible = false;
lblFee.Text = "There is a $5 shipping fee";
lblFee.Visible = true;
lblError.Text = "";}
}
}
}
You can use int.TryParse which returns a boolean and does not throw an exception.
int numTick = 0;
bool result = int.TryParse(txtNumberOfTickets.Text, out numTick );
You can also do some client side validation to ensure that the field is filled in and contains a number.
Here is one of your methods rewritten using Int32.TryParse. I assumed you're doing txtTotalCost.Substring(1) to trim off the currency symbol. There are probably safe ways to do this, I'm just going to trim "$" for this example.
protected void btnOrderTickets_Click(object sender, EventArgs e)
{
int numberOfTickets, ticketCost, eventId;
if(Int32.TryParse(txtNumberOfTickets.Text, out numberOfTickets) &&
Int32.TryParse(txtTotalCost.Text.TrimStart('$'), out ticketCost) &&
Int32.TryParse(txtEventID.Text, out eventId))
{
DateTime dt = Convert.ToDateTime(Session["date"]);
TicketsDataAccessDataContext NewOrder = new TicketsDataAccessDataContext();
int returnedValue = NewOrder.PlaceOrderFull(eventId, txtEventDescription.Text, dt, Session["State"].ToString(), Session["section"].ToString(), Session["Row"].ToString(), numberOfTickets, ticketCost, "vfateev");
if (returnedValue != 0)
{
lblOutput.Text = "Error has occured. Please try again";
lblOutput.Visible = true;
btnOrderTickets.Visible = false;
}
else
{
lblOutput.Visible = true;
lblOutput.Text = "Thank you";
btnOrderTickets.Visible = false;
}
}
else
{
lblOutput.Visible = true;
lblOutput.Text = "Some validation error message here...";
}
}
You will need to make similar modifications to txtNumberOfTickets_TextChanged1 to ensure the user has entered valid text.
simply use something like
To use IsNumeric in C#, add a reference to Microsoft.VisualBasic.dll then
if (Information.IsNumeric(value))
{
DoSomthing();
}
else
{
DoSomethingElse();
}
UPDATE
OPEN VISUAL STUDIO ==> YOUR PROJECT
Click on solution and add reference, choose Microsoft.VisualBasic.dll confrim the new reference will be add to your references into the project.
Go at the top of your page and declare the import statemnet for Microsoft.VisualBasic.dll alias
using Microsoft.VisualBasic.dll;
then where you need to check the value of your textbox
if (Information.IsNumeric(yourtextbox.text.trim()))
{
//case true alias your value is numeric
//do what you need here like assing value to a var or any
//else
}
else
{
//put your logic here in case result is false and value
//is not numeric
}
I am working on a project (simple phone book) for personal use. This is how it looks like:
I have a listview filled with contacts and everything was working perfectly untill I added this line of code, when everything became messed up.
listView1.Sorting = SortOrder.Ascending;
So, the problem is obvious. Let's say that there are 6 contacts in the list, and Contact 1 lives in City 1, on Address 1, has a Tel. No 1 [etc], and Contact 2 lives in City 2, on Address 2, has a Tel. No 2 etc. [...sequence continues...]
When I try to make some changes, for example, Contact 5 suddenly gets the information of other contact, in this case, Contact 7. It doesn't matter whose information it gets though, the matter is that everything becomes messed up.
Also, if i want to delete all the contacts from the listview - it is not possible - there will always be one remaining. For example, if there were 6 of them, 5 would be deleted and there would be one left. Also, if there was 100 of them, it would delete 99 and the one would always remain as well.
I figured out that there is no sense to use index of selected item anymore and that I have to use value of the selected item now (instead of its index). But, the problem is I do not know how to do that.
Maybe it comes to listView1_SelectedIndexChanged only. Please note that i am just taking a guess, I am not completely sure.
If so, here is the code:
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
textBox1.Text = people[listView1.SelectedItems[0].Index].Name;
textBox2.Text = people[listView1.SelectedItems[0].Index].Hometown;
textBox3.Text = people[listView1.SelectedItems[0].Index].Address;
textBox4.Text = people[listView1.SelectedItems[0].Index].Phone;
textBox5.Text = people[listView1.SelectedItems[0].Index].Email;
textBox6.Text = people[listView1.SelectedItems[0].Index].AdditionalInfo;
dateTimePicker1.Value = people[listView1.SelectedItems[0].Index].Birthday;
textBox1.ReadOnly = true;
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
dateTimePicker1.Enabled = false;
toolStripButton5.Enabled = true;
}
I think the code is to big to upload it here, so I uploaded the code here:
Does anyone have a solution?
In order to find the right object to update you first need to find the object in the People collection that matches the object selected in the ListView.
Person i = People.FirstOrDefault(p => p.Name == ((ListView) sender).SelectedItems[0].Text);
PopulateEditData(i); // refer below for method...
This can only work if you have the MultiSelect property set to false, otherwise you will need to get the right item from the collection of selected items.
As seen here: http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.selecteditems(v=vs.110).aspx
Once you have the right Person object, you will be able to retrieve and display the objects details in the text boxes:
private void PopulateEditData(Person selectedPerson)
{
textBox1.Text = selectedPerson.Name;
textBox2.Text = selectedPerson.Hometown;
textBox3.Text = selectedPerson.Address;
textBox4.Text = selectedPerson.Phone;
textBox5.Text = selectedPerson.Email;
textBox6.Text = selectedPerson.AdditionalInfo;
dateTimePicker1.Value = selectedPerson.Birthday;
textBox1.ReadOnly = true;
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
dateTimePicker1.Enabled = false;
toolStripButton5.Enabled = true;
}
I would also suggest setting the selectPerson as a property of your form or one of the classes available to it so it is a little easier to edit and save the data on the object.
For the removal part of the problem, use the SelectedPerson property for the item to be removed.
private void button1_Click(object sender, EventArgs e)
{
if (SelectedPerson != null)
{
People.Remove(SelectedPerson);
this.listView1.Items.Clear();
foreach (var person in People)
{
this.listView1.Items.Add(person.ToString());
this.listView1.Sorting = SortOrder.Ascending;
}
this.listView1.Refresh();
this.button1.Enabled = false;
}
}
Thank you for your answer.
Anyway, I have managed to solve the problem in the following way:
1) I have added:
private Person FindPerson(string name)
{
return people.Find(x => x.Name == name);
}
2) I have replaced:
people[listView1.SelectedItems[0].Index]
with "person", where person is:
Person person = FindPerson(listView1.SelectedItems[0].Text);
where FindPerson is:
private Person FindPerson(string name)
{
return people.Find(x => x.Name == name);
}
Anyway, I keep getting error when I try to remove the last remaining contact. Even when I try to select it, not just remove it. Here you can take a look what error is about:
IMAGE: http://s24.postimg.org/ls4nak6et/Kruzeri.png
So, this is how it looks like now:
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
Person person = FindPerson(listView1.SelectedItems[0].Text);
textBox1.Text = person.Name;
textBox2.Text = person.Hometown;
textBox3.Text = person.Address;
textBox4.Text = person.Phone;
textBox5.Text = person.Email;
textBox6.Text = person.AdditionalInfo;
dateTimePicker1.Value = person.Birthday;
textBox1.ReadOnly = true;
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
dateTimePicker1.Enabled = false;
toolStripButton5.Enabled = true;
}
and Save button:
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
Person person = FindPerson(listView1.SelectedItems[0].Text);
person.Name = textBox1.Text;
person.Hometown = textBox2.Text;
person.Address = textBox3.Text;
person.Phone = textBox4.Text;
person.Email = textBox5.Text;
person.Birthday = dateTimePicker1.Value;
person.AdditionalInfo = textBox6.Text;
listView1.SelectedItems[0].Text = textBox1.Text;
textBox1.ReadOnly = true;
textBox2.ReadOnly = true;
textBox3.ReadOnly = true;
textBox4.ReadOnly = true;
textBox5.ReadOnly = true;
textBox6.ReadOnly = true;
dateTimePicker1.Enabled = false;
}
else
{
MessageBox.Show("Nothing is selected ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
UserCount();
}
Your function returns null because no item is selected. So person is of course null. You should handle this in your FindPerson-Function.
Below is the code of my simple page's submit button click. I am submitting an empty form but no server validation error messages are showing. What's wrong with my code? When I click on submit, the page just turns blank and nothing happens. I am also unable to attach the debugger.
When I am building my website project, it is not showing any compilation error either. I don't know what I am doing wrong.
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Need to Validate All Required Fields before redirecting to frmPersonalVerified.aspx
bool blnFormIsValid = true;
DateTime dtEndDate;
DateTime dtStartDate;
// Get Date because we have a value.
dtEndDate = DateTime.Parse(txtEndDate.Text);
// Get Date because we have a value.
dtStartDate = DateTime.Parse(txtStartDate.Text);
if (txtFirstName.Text.Trim() == "")
{
txtFirstName.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please enter first name.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtFirstName.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
if (txtLastName.Text.Trim() == "")
{
txtLastName.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please enter last name.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtLastName.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
if (txtPayRate.Text.Trim() == "")
{
txtPayRate.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please enter pay rate.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtPayRate.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
if (txtStartDate.Text.Trim() == "")
{
txtStartDate.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please enter start date.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtStartDate.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
if (txtEndDate.Text.Trim() == "")
{
txtEndDate.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please enter end date.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtEndDate.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
// Compare Dates
if (DateTime.Compare(dtStartDate, dtEndDate) >= 0)
{
txtStartDate.BackColor = System.Drawing.Color.Yellow;
txtEndDate.BackColor = System.Drawing.Color.Yellow;
lblError.Text = "Please make sure that start date is less than end date.";
blnFormIsValid = false;
}
else
{
lblError.Text = "";
txtStartDate.BackColor = System.Drawing.Color.White;
txtEndDate.BackColor = System.Drawing.Color.White;
blnFormIsValid = true;
}
if (blnFormIsValid == true)
{
//Assign a value to the session variable.
Session["FirstName"] = txtFirstName.Text;
Session["LastName"] = txtLastName.Text;
Session["PayRate"] = txtPayRate.Text;
Session["StartDate"] = txtStartDate.Text;
Session["EndDate"] = txtEndDate.Text;
// Sends A Request from the Browser to the server.
Response.Redirect("frmPersonalVerified.aspx");
}
}
Update
I just used .Equals("")... it's not working. Still blank page is showing up
Ignoring the fact that the correct way is to use ASP.NET's built-in validation tools, the problem is that your program's logic is broken.
You're using blnFormIsValid to store the validity of the form, however its value is meaningless because you're assigning it without paying attention to previous state.
If I submit your page's form with these values...
txtFirstName = "" // this is invalid
txtLastName = "foo" // this is valid
...then it will correctly fail the first validation and blnFormIsValid will be false, however your next check ignores the state of blnFormIsValid and sets it to true simply because txtLastName's value is valid.
This issue stems not from our lack of understanding or knowledge of ASP.NET, but basic programming and logic. A simple step-through or dry-run of your code would have revealed this.
Below are my list of recommendations:
Use ASP.NET Validation controls, like so:
<input type="text" id="firstName" runat="server" />
<asp:RequiredValidator runat="server" controlToValidate="firstName" />
void Page_Load() {
if( Page.IsPostBack) {
Page.Validate();
if( Page.IsValid ) {
// that's all you have to do
}
}
Don't use Hungarian notation
This is when you prefix an identifier with a tag that identifies its type, e.g. "blnFormIsValid" or "txtFirstName". Just use "formIsValid" or "firstName". Hungarian notation is only of use in environments where typing information is not provided by the editor.
Don't use foo == true
... because the operation will evaluate to the same value as foo. In your case you should have if( formIsValid ) instead of if( formIsValid == true ). Avoiding unnecessary use of the == operator can help avoid cases where you accidentally use the = assignment operator instead of the == equality operator (and make your code more readable).
I have created a contact form using c# and web services. I would like to get an alert message if the user hasn't filled his name or when his name is a number. This is my C# code:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Validation.WebService validate = new Validation.WebService();
bool ismail = validate.isEmail(TextBox2.Text);
if (!ismail)
{ Label1.Text = "your mail is wrong!!"; }
Validation.nameVal valid = new Validation.nameVal();
bool isname = valid.isName(TextBox1.Text);
if (!isname )
{ Label2.Text = "Your name is wrong!!"; }
else if (isname==null)
{ Label2.Text = "Please fill in your name"; }
if (isname && ismail)
{
{ Label1.Text = null; Label2.Text = null;
Label3.Text = "Your message has been send!";}
}
}
}
With this code, I have a null exception.
From your comment that the exception is on the line:
bool isname = valid.isName(TextBox1.Text);
then either valid or TextBox1 is null. Given that the line before is:
Validation.nameVal valid = new Validation.nameVal();
this points to it being the latter.
You need to check that TextBox1 isn't null before de-referencing it or make sure that it is initialised correctly.
Try changing the last bit of the code where you set Label1.Text and Label2.Text to null to:
Label1.Text = String.Empty; Label2.Text = String.Empty;
I am guessing that perhaps the validate is failing, or, possibly the setting of the label text to null is causing the issues. The code below should help
Validation.WebService validate = new Validation.WebService();
bool ismail = (!string.IsNullOrEmpty(Textbox2.Text)) && validate.isEmail(TextBox2.Text);
if (!ismail)
{
Label1.Text = "your mail is wrong!!";
}
Validation.nameVal valid = new Validation.nameVal();
bool isname = (!string.IsNullOrEmpty(Textbox1.Text)) && valid.isName(TextBox1.Text);
if (!isname)
{
Label2.Text = "Your name is wrong!!";
}
else if (string.IsNullOrEmpty(Textbox1.Text))
{
Label2.Text = "Please fill in your name";
}
if (isname && ismail)
{
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "Your message has been send!";
}
}
}