protected void Register_Click(object sender, EventArgs e) { if (textName.Text != "" && labelHost.Text != "::1" && listCanvas.SelectedIndex >= 0 && listLocation.SelectedIndex >= 0 ) { try { Display display = new Display() { Host = labelHost.Text, Name = textName.Text, CanvasId = Convert.ToInt32(listCanvas.SelectedValue), LocationId = Convert.ToInt32(listLocation.SelectedValue), }; display.Register(); HttpContext.Current.Response.Redirect("default.aspx"); } catch (Exception ex) { Response.Write(ex.Message); // TODO: error label } } }