using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
public class Registration : Page {
protected TextBox name;
protected TextBox firstName;
protected TextBox email;
protected CheckBox workshop;
protected RadioButton programmer;
protected RadioButton webDesigner;
protected RadioButton manager;
protected Button submit;
protected Label message;
public void Register(object sender, EventArgs e) {
if (name.Text == "")
message.Text = "Please fill in all text fields";
else {
try {
FileStream s = new FileStream(Server.MapPath("registrations.txt"), FileMode.Append, FileAccess.Write);
StreamWriter w = new StreamWriter(s, Encoding.UTF8);
w.Write(name.Text + " " + firstName.Text + " " + email.Text);
if (workshop.Checked) w.Write(" +workshop");
if (programmer.Checked) w.Write(" programmer");
else if (webDesigner.Checked) w.Write(" designer");
else if (manager.Checked) w.Write(" manager");
w.WriteLine();
w.Flush();
s.Close();
message.Text = "Thank you for registering";
} catch (IOException) {
message.Text = "An error occurred while processing your request";
}
}
}
}
|