// Add protected void ButtonAdd_Click(object sender, EventArgs e) { ListBoxContacts.Items.Add($"{TextBoxFirstname.Text} {TextBoxLastname.Text}"); SQL.AddContact(TextBoxFirstname.Text, TextBoxLastname.Text, TextBoxSSN.Text); TextBoxFirstname.Text = ""; TextBoxLastname.Text = ""; TextBoxSSN.Text = ""; }
protected void ButtonAddPerson_Click(object sender, EventArgs e) { if (SQL.CheckSSN(ssn)) { SQL.AddContact(name, lastname, ssn); } else { //Literal1.Text = ("Alert, " "<script language ") FIXA TILL ALERT SENARE } UpdateListbox(); ClearTextbox(); }
protected void ButtonAddContact_Click(object sender, EventArgs e) { string firstname = TextBoxFirstname.Text; string lastname = TextBoxLastname.Text; string ssn = TextBoxSSN.Text; SQL.AddContact(firstname, lastname, ssn); ListBoxContacts.Items.Clear(); foreach (var p in SQL.ImportData()) { ListBoxContacts.Items.Add($"{p.FirstName} {p.LastName}"); } }
protected void Page_Load(object sender, EventArgs e) { List <Contact> contacts = SQL.ImportData(); JSONLiteral.Text = JsonConvert.SerializeObject(contacts); if (Request["action"] != null) { string action = Request["action"].ToString(); if (action == "addcontact") { string firstName = Request["firstname"]; string lastName = Request["lastname"]; string ssn = Request["ssn"]; SQL.AddContact(firstName, lastName, ssn); JSONLiteral.Text = JsonConvert.SerializeObject("ok"); } } }