protected void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(edLogin.Text)) { this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.InvalidLogin); return; } if (Request.QueryString.GetValues("Target") == null || Request.QueryString.GetValues("ReturnUrl") == null) { this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.InvalidQueryString); return; } string link = HttpContext.Current.Request.GetWebsiteUrl().TrimEnd('/'); link += Request.QueryString.GetValues("Target")[0]; link += "?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString.GetValues("ReturnUrl")[0]); string[] companies = PXDatabase.Companies; bool anySuccess = false; string errorMsg = null; if (companies.Length > 0) { if (!PXDatabase.SecureCompanyID) { companies = new string[] { cmbCompany.SelectedItem.Value } } ; foreach (string companyID in companies) { try { PXDatabase.ResetCredentials(); PXLogin.SendUserPassword( edLogin.Text + "@" + companyID, link + "&cid=" + HttpUtility.UrlEncode(companyID), "gk"); anySuccess = true; } catch (Exception ex) { errorMsg = ex.Message; } } } else { try { PXLogin.SendUserPassword(edLogin.Text, link, "gk"); anySuccess = true; } catch (Exception ex) { errorMsg = ex.Message; } } if (anySuccess) { //lblMsg.ForeColor = System.Drawing.Color.Black; this.Master.Message = PX.Data.PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.PasswordSent); LiteralControl metaRefresh = new LiteralControl("<meta http-equiv=\"Refresh\" content=\"4;URL=" + link + "\" />"); Page.Header.Controls.Add(metaRefresh); } else if (!String.IsNullOrEmpty(errorMsg)) { this.Master.Message = errorMsg; } }