protected void btnSaveChanges_Click(object sender, System.EventArgs e)
        {
            BrokerDB brokerDB = new BrokerDB();

            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();

            if(txtNewPassword.Text.CompareTo(txtConfirmPassword.Text) != 0 )
            {
                lblResponse.Text = Utilities.FormatErrorMessage("Password fields don't match. Try again!");
                lblResponse.Visible = true;
                txtNewPassword.Text = null;
                txtConfirmPassword.Text = null;
            }
            else
            {
                //if a field is left blank, it is not updated
                try
                {
                    User userInfo = wrapper.GetUsersWrapper(new int[] {Convert.ToInt32(Session["UserID"])})[0];
                    Authority auth = brokerDB.AuthorityRetrieve(userInfo.authID);
                    if (txtUsername.Text.Trim()=="")
                    {
                        txtUsername.Text = userInfo.userName;
                    }
                    if(txtFirstName.Text.Trim() == "")
                    {
                        txtFirstName.Text = userInfo.firstName ;
                    }
                    if(txtLastName.Text.Trim() == "")
                    {
                        txtLastName.Text = userInfo.lastName ;
                    }
                    if(txtEmail.Text.Trim() == "")
                    {
                        txtEmail.Text = userInfo.email ;
                    }

                    if (userInfo.reason==null)
                        userInfo.reason = "";
                    if (userInfo.affiliation==null)
                        userInfo.affiliation="";
                    if (userInfo.xmlExtension==null)
                        userInfo.xmlExtension="";

                    wrapper.ModifyUserWrapper (userInfo.userID,txtUsername.Text,auth.authorityID,auth.authTypeID,
                        txtFirstName.Text , txtLastName.Text , txtEmail.Text ,userInfo.affiliation, userInfo.reason,
                        userInfo.xmlExtension,userInfo.lockAccount );
                    lblResponse.Text = Utilities.FormatConfirmationMessage("User \"" + txtUsername.Text  + "\" information has been updated.");
                    lblResponse.Visible = true;
                    if (auth.authTypeID == (int) AuthenticationType.AuthTypeID.Native)
                    {
                        if (txtNewPassword.Text != "")
                        {
                            wrapper.SetNativePasswordWrapper(Convert.ToInt32(Session["UserID"]), txtNewPassword.Text);
                        }
                    }
                    if (txtUsername.Text.CompareTo(Session["UserName"].ToString())!= 0)
                        Session["UserName"]= txtUsername.Text;

                    // Send a confirmation message to the user
                    string email;
                    if(txtEmail.Text.Trim() == "")
                    {
                        // use old email if it wasn't changed, new if it was
                        email = userInfo.email;
                    }
                    else
                    {
                        email = txtEmail.Text.Trim();
                    }
                    if (email != null && email.Length > 0)
                    {
                        MailMessage mail = new MailMessage();
                        mail.From = registrationMailAddress;
                        mail.To = email;
                        mail.Subject = "[iLabs] Service Broker Account Update Confirmation";
                        mail.Body = "Your Service Broker account has been updated to the following:\n\r";
                        mail.Body += "-------------------------------------------------------------\n\r\n\r";
                        mail.Body += "User Name: " + txtUsername.Text + "\n\r";
                        mail.Body += "First Name: " + txtFirstName.Text + "\n\r";
                        mail.Body += "Last Name: " + txtLastName.Text + "\n\r";
                        mail.Body += "Email: " + txtEmail.Text + "\n\r\n\r";
                        mail.Body += "For security reasons, your password has not been included in this message." + "\n\r";

                        SmtpMail.SmtpServer = "127.0.0.1";
                        try
                        {
                            SmtpMail.Send(mail);
                        }
                        catch(Exception e2)
                        {
                            // if the confirmation message fails, c'est la vie...
                            string msg = "Error sending email notification: (" + e2.Message + ". " + e2.GetBaseException() + "). Contact " + supportMailAddress + ".";
                            lblResponse.Text = Utilities.FormatErrorMessage(msg);
                            lblResponse.Visible = true;

                        }
                    }
                }
                catch (Exception ex)
                {
                    string msg = "Error updating account ("+ex.Message+". "+ex.GetBaseException()+"). Contact " + supportMailAddress + ".";
                    lblResponse.Text = Utilities.FormatErrorMessage(msg);
                    lblResponse.Visible = true;
                }
            }
        }