private void AddDialogButtons() { CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save & close button LocalizedButton btnSaveAnClose = new LocalizedButton { ID = "btnSaveCancel", ResourceString = "general.saveandclose", EnableViewState = false, CssClass = "LongSubmitButton" }; btnSaveAnClose.Click += (sender, e) => { if (Save()) { ScriptHelper.RegisterStartupScript(this, GetType(), "SaveAndClose", "window.top.close();", true); } }; CurrentMaster.PanelFooter.Controls.Add(btnSaveAnClose); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.top.close(); return false;", CssClass = "SubmitButton" }); }
/// <summary> /// Sets SkinId to all controls in logon form. /// </summary> private void SetSkinID(string skinId) { if (skinId != string.Empty) { loginElem.SkinID = skinId; user = (TextBox)loginElem.FindControl("UserName"); if (user != null) { user.SkinID = skinId; } pass = (TextBox)loginElem.FindControl("Password"); if (pass != null) { pass.SkinID = skinId; } login = (LocalizedButton)loginElem.FindControl("btnLogon"); if (login != null) { login.SkinID = skinId; } loginImg = (ImageButton)loginElem.FindControl("btnImageLogon"); if (loginImg != null) { loginImg.SkinID = skinId; } } }
protected override void OnPreInit(EventArgs e) { // Set up dialog mode IsDialog = QueryHelper.GetBoolean("dialog", false); base.OnPreInit(e); if (IsDialog) { MasterPageFile = "~/CMSMasterPages/UI/Dialogs/ModalDialogPage.master"; if (Master == null) { return; } // Get footer placeholder var footer = (ContentPlaceHolder)Master.FindControl("plcFooter"); if (footer == null) { return; } // Add button var button = new LocalizedButton { ButtonStyle = ButtonStyle.Primary, ResourceString = "general.translate", EnableViewState = false }; button.Click += btnTranslate_Click; footer.Controls.Add(button); } }
/// <summary> /// Sets forgotten password mode. /// </summary> private void SetForgottenPasswordMode() { LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.ResourceString = "LogonForm.SendRequest"; btnItem.CommandName = string.Empty; } TextBox txtPassword = (TextBox)Login1.FindControl("Password"); if (txtPassword != null) { txtPassword.Visible = false; } LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Visible = false; } CheckBox chkRemeber = (CheckBox)Login1.FindControl("chkRememberMe"); if (chkRemeber != null) { chkRemeber.Visible = false; } LocalizedLabel lblLogOn = (LocalizedLabel)Login1.FindControl("lblLogOn"); if (lblLogOn != null) { lblLogOn.ResourceString = "logonform.lnkpasswordretrieval"; } LocalizedLabel lblUserName = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.ResourceString = "logonform.lblpasswordretrieval"; } ImageButton lnkPassword = (ImageButton)Login1.FindControl("lnkPassword"); if (lnkPassword != null) { lnkPassword.ToolTip = GetString("logonform.logonbutton"); } tablePadding = "TablePadding"; labelClass += " PasswordLabel"; IsForgottenPassword = true; }
private void SetDialogMode(CssStylesheetInfo si) { // Check if stylesheet is under curent site int siteId = (CurrentSite != null) ? CurrentSite.SiteID : 0; string where = SqlHelperClass.AddWhereCondition("SiteID = " + siteId, "StylesheetID = " + si.StylesheetID); DataSet ds = CssStylesheetSiteInfoProvider.GetCssStylesheetSites("StylesheetID", where, null, 1); if (DataHelper.DataSourceIsEmpty(ds)) { URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("cssstylesheet.errorediting"), ResHelper.GetString("cssstylesheet.notallowedtoedit")))); } // Set CSS classes CurrentMaster.PanelContent.CssClass = "PageContent"; CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save and close button LocalizedButton btnSaveAndCancel = new LocalizedButton { ID = "btnSaveCancel", ResourceString = "general.saveandclose", EnableViewState = false, CssClass = "LongSubmitButton" }; btnSaveAndCancel.Click += (sender, e) => { if (Save()) { ScriptHelper.RegisterStartupScript(this, GetType(), "SaveAndClose", "window.top.close();", true); } }; CurrentMaster.PanelFooter.Controls.Add(btnSaveAndCancel); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnClose", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.top.close(); return false;", CssClass = "SubmitButton" }); // Set CMS master page title CurrentMaster.Title.TitleText = GetString("CssStylesheet.EditCssStylesheet"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_CSSStylesheet/object.png"); // Disable display and code name editing //txtCssStylesheetDisplayName.ReadOnly = txtCssStylesheetName.ReadOnly = true; }
private void SetDialogMode() { // Check if user can edit the stylesheet CurrentUserInfo currentUser = CMSContext.CurrentUser; string siteName = (CurrentSite != null) ? CurrentSite.SiteName : string.Empty; if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design" }, siteName)) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Properties;Properties.General;General.Design"); } // Hide OK button btnOk.Visible = false; CurrentMaster.PanelContent.CssClass = "PageContent"; CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", EnableViewState = false, CssClass = "SubmitButton" }; btnSave.Click += (sender, e) => Save(false); CurrentMaster.PanelFooter.Controls.Add(btnSave); // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.close(); return false;", CssClass = "SubmitButton" }); }
private void SetDialogButtons() { mCurrentMaster.PanelFooter.CssClass = "FloatRight"; // Create new transformation if (!EditMode) { // Hide header actions when creating new transformation in dialog mCurrentMaster.HeaderActions.Parent.Visible = false; // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", EnableViewState = false, CssClass = "SubmitButton" }; btnSave.Click += (sender, e) => Save(false); mCurrentMaster.PanelFooter.Controls.Add(btnSave); } // Add save & close button LocalizedButton btnSaveAndCancel = new LocalizedButton { ID = "btnSaveCancel", ResourceString = "general.saveandclose", EnableViewState = false, CssClass = "LongSubmitButton" }; btnSaveAndCancel.Click += (sender, e) => { if (Save(true)) { // Need to register one more window close because of the postback ScriptHelper.RegisterStartupScript(this, GetType(), "SaveAndClose", "window.top.close();", true); } }; mCurrentMaster.PanelFooter.Controls.Add(btnSaveAndCancel); // Add close button every time mCurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.top.close(); return false;", CssClass = "SubmitButton" }); }
public override void OnInit() { btnSelect = new LocalizedButton(); page = ((CMSUIPage)Control.Page); btnSelect.ResourceString = "general.select"; btnSelect.Click += btnSelectClick; btnSelect.ID = "btnSelect"; page.DialogFooter.AddControl(btnSelect); page.DialogFooter.HideCancelButton(); if (!RequestHelper.IsPostBack()) { SessionHelper.Remove("DialogSelectedParameters"); } }
private void SetDialogMode() { if (!TabMode) { SetTitle(mIsEditMode ? "Objects/CMS_Query/object.png" : "Objects/CMS_Query/query_new.png", mIsEditMode ? GetString("query.edit") : GetString("query.new"), "newedit_query", "helpTopic"); } CurrentMaster.PanelFooter.CssClass = "FloatRight"; if (!mIsEditMode) { // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", CssClass = "SubmitButton", Visible = queryEdit.Visible, EnableViewState = false }; btnSave.Click += (sender, e) => queryEdit.Save(false); CurrentMaster.PanelFooter.Controls.Add(btnSave); } // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", Visible = queryEdit.Visible, EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => queryEdit.Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button every time CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnClose", ResourceString = "general.close", EnableViewState = false, OnClientClick = "return CloseDialog();", CssClass = "SubmitButton" }); // Set refresh URL so that we don't lose dialog mode queryEdit.RefreshPageURL = "~/CMSModules/DocumentTypes/Pages/Development/DocumentType_Edit_Query_Edit.aspx"; }
public LocalizedButton AddTranslationButton(MovieClip _mc, string _text, EventDispatcher.EventCallback BtnClickCallback, LocalizedButton.Alignment _alignment, bool _resizable = true, bool _icon = false, string _iconLabel = "") { LocalizedButton localizedButton; if (localizedButtonList.ContainsKey(_mc)) { localizedButtonList.TryGetValue(_mc, out localizedButton); //_translationText = new TranslationText(_textfield, txt); TODO } else { localizedButton = new LocalizedButton(_mc, _text, BtnClickCallback, _alignment, _resizable, _icon, _iconLabel); localizedButtonList.Add(_mc, localizedButton); } return(localizedButton); }
public LocalizedButton AddTranslationButton(Button _mc, string _text) { LocalizedButton localizedButton; if (localizedButtonList.ContainsKey(_mc)) { localizedButtonList.TryGetValue(_mc, out localizedButton); localizedButton = new LocalizedButton(_mc, _text); //_translationText = new TranslationText(_textfield, txt); TODO } else { localizedButton = new LocalizedButton(_mc, _text); localizedButtonList.Add(_mc, localizedButton); } return localizedButton; }
private void SetDialogButtons() { CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", EnableViewState = false, CssClass = "SubmitButton" }; btnSave.Click += (sender, e) => editElem.Save(true); mCurrentMaster.PanelFooter.Controls.Add(btnSave); // Add save & close button LocalizedButton btnSaveAndCancel = new LocalizedButton { ID = "btnSaveCancel", ResourceString = "general.saveandclose", EnableViewState = false, CssClass = "LongSubmitButton" }; btnSaveAndCancel.Click += (sender, e) => { if (editElem.Save(false)) { // Register script for save value to uniselector and close the window UpdateUniSelector(true); } }; mCurrentMaster.PanelFooter.Controls.Add(btnSaveAndCancel); // Add close button every time mCurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.top.close(); return false;", CssClass = "SubmitButton" }); }
/// <summary> /// Sets SkinId to all controls in logon form. /// </summary> private void SetSkinID(string skinId) { if (skinId != "") { Login1.SkinID = skinId; LocalizedLabel lbl = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lbl != null) { lbl.SkinID = skinId; } lbl = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lbl != null) { lbl.SkinID = skinId; } TextBox txt = (TextBox)Login1.FindControl("UserName"); if (txt != null) { txt.SkinID = skinId; } txt = (TextBox)Login1.FindControl("Password"); if (txt != null) { txt.SkinID = skinId; } LocalizedCheckBox chk = (LocalizedCheckBox)Login1.FindControl("chkRememberMe"); if (chk != null) { chk.SkinID = skinId; } LocalizedButton btn = (LocalizedButton)Login1.FindControl("LoginButton"); if (btn != null) { btn.SkinID = skinId; } } }
private void SetDialogMode() { // When in modal dialog, the margins have to be increased CurrentMaster.PanelContent.CssClass = "PageContent"; CurrentMaster.PanelFooter.CssClass = "FloatRight"; btnOk.ResourceString = GetString("general.save"); btnOk.Parent.Controls.Remove(btnOk); // Add save button CurrentMaster.PanelFooter.Controls.Add(btnOk); // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "window.close(); return false;", CssClass = "SubmitButton" }); // When in modal dialog, the window scrolls to bottom, so this hack will scroll it back to top string scrollScript = "var scrollerDiv = document.getElementById('divContent'); if (scrollerDiv != null) setTimeout(function() { scrollerDiv.scrollTop = 0; }, 500);"; ScriptHelper.RegisterStartupScript(this, GetType(), "ScrollTop", scrollScript, true); }
private void CreateFooterButtons() { CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save button LocalizedButton btnSave = new LocalizedButton() { ID = "btnSave", ResourceString = "general.save", CssClass = "SubmitButton", EnableViewState = false }; btnSave.Click += (sender, e) => emailTemplateEditElem.Save(false); CurrentMaster.PanelFooter.Controls.Add(btnSave); // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton() { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => emailTemplateEditElem.Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button every time CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton() { ID = "btnClose", ResourceString = "general.close", EnableViewState = false, OnClientClick = "return CloseDialog();", CssClass = "SubmitButton" }); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!IsDialog) { HandleBreadcrumbsScripts(); } else { if (CurrentMaster.PanelFooter != null) { var closeButton = new LocalizedButton { ID = "btnClose", ResourceString = "general.close", OnClientClick = "CloseDialog(); return false;", ButtonStyle = ButtonStyle.Default, EnableViewState = false }; CurrentMaster.PanelFooter.Controls.Add(closeButton); } } }
/// <summary> /// Sets forgotten password mode. /// </summary> private void SetForgottenPasswordMode() { var plcPasscodeBox = Login1.FindControl("plcPasscodeBox"); if (plcPasscodeBox != null) { plcPasscodeBox.Visible = false; } var plcLoginInputs = Login1.FindControl("plcLoginInputs"); if (plcLoginInputs != null) { plcLoginInputs.Visible = true; } var plcTokenInfo = Login1.FindControl("plcTokenInfo"); if (plcTokenInfo != null) { plcTokenInfo.Visible = false; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.ResourceString = "LogonForm.SendRequest"; btnItem.CommandName = string.Empty; } TextBox txtPassword = (TextBox)Login1.FindControl("Password"); if (txtPassword != null) { txtPassword.Visible = false; } LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Visible = false; } CMSCheckBox chkRemeber = (CMSCheckBox)Login1.FindControl("chkRememberMe"); if (chkRemeber != null) { chkRemeber.Visible = false; } MainTextResString = "logonform.lnkpasswordretrieval"; LocalizedLabel lblUserName = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.ResourceString = "logonform.lblpasswordretrieval"; } RequiredFieldValidator rfvUserName = (RequiredFieldValidator)Login1.FindControl("rfvUserNameRequired"); if (rfvUserName != null) { rfvUserName.ToolTip = GetString("LogonForm.NameOrEmailRequired"); rfvUserName.Text = rfvUserName.ErrorMessage = GetString("logonform.rqvalue"); } var lnkPassword = Login1.FindControl("lnkPassword") as LocalizedLinkButton; if (lnkPassword != null) { lnkPassword.ResourceString = "LogonForm.BackToLogon"; } IsForgottenPassword = true; }
protected void Page_Load(object sender, EventArgs e) { SetBrowserClass(); AddNoCacheTag(); HideErrorWarnings(); MainTextResString = "LogonForm.LogOn"; // Ensure the refresh script const string defaultCondition = "((top.frames['cmsdesktop'] != null) || (top.frames['propheader'] != null))"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "TopWindow", ScriptHelper.GetScript(" if " + defaultCondition + " { try {top.window.location.reload();} catch(err){} }")); // Enable caps lock check if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSUseCapsLockNotification"], true)) { RegisterCAPSLOCKScript(); TextBox txtPassword = (TextBox)Login1.FindControl("Password"); if (txtPassword != null) { txtPassword.Attributes.Add("onkeypress", "CheckCapsLock(event)"); } } LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblItem != null) { lblItem.Text = "{$LogonForm.UserName$}"; } lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Text = "{$LogonForm.Password$}"; } // Display culture link due to value of the key stored in the web.config file bool showCultureSelector = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSShowLogonCultureSelector"], true); if (showCultureSelector) { LocalizedLinkButton lnkLanguage = (LocalizedLinkButton)Login1.FindControl("lnkLanguage"); if (lnkLanguage != null) { lnkLanguage.Visible = true; // Ensure language selection panel functionality HtmlGenericControl pnlLanguage = (HtmlGenericControl)Login1.FindControl("pnlLanguage"); if (pnlLanguage != null) { ltlScript.Text = ScriptHelper.GetScript("function ShowLanguage(id){var panel=document.getElementById(id);if(panel!=null){panel.style.display=(panel.style.display == 'block')?'none':'block';}}"); lnkLanguage.Attributes.Add("onclick", "ShowLanguage('" + pnlLanguage.ClientID + "'); return false;"); } } } // Set up forgotten password link if (ShowForgottenPassword) { LocalizedLinkButton lnkPassword = (LocalizedLinkButton)Login1.FindControl("lnkPassword"); if (lnkPassword != null) { lnkPassword.Visible = true; lnkPassword.Click += lnkPassword_Click; } } PlaceHolder plcRemeberMe = (PlaceHolder)Login1.FindControl("plcRemeberMe"); if ((MFAuthenticationHelper.IsMultiFactorAutEnabled) && (plcRemeberMe != null)) { plcRemeberMe.Visible = false; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.Text = "{$LogonForm.LogOnButton$}"; btnItem.Click += btnItem_Click; } // Load UI cultures for the dropdown list if (!RequestHelper.IsPostBack()) { LoadCultures(); } Login1.LoggingIn += Login1_LoggingIn; Login1.LoggedIn += Login1_LoggedIn; Login1.LoginError += Login1_LoginError; Login1.Authenticate += Login1_Authenticate; if (!RequestHelper.IsPostBack()) { Login1.UserName = QueryHelper.GetString("username", String.Empty); } // Ensure username textbox focus CMSTextBox txtUserName = (CMSTextBox)Login1.FindControl("UserName"); if (txtUserName != null) { ScriptHelper.RegisterStartupScript(this, GetType(), "SetFocus", ScriptHelper.GetScript("var txt=document.getElementById('" + txtUserName.ClientID + "');if(txt!=null){txt.focus();}")); txtUserName.EnableAutoComplete = SecurityHelper.IsAutoCompleteEnabledForLogin(SiteContext.CurrentSiteName); } if (QueryHelper.GetBoolean("forgottenpassword", false)) { SetForgottenPasswordMode(); } // Register script to update logon error message StringBuilder sbScript = new StringBuilder(); sbScript.Append(@" var failedText_", ClientID, "= document.getElementById('", FailureLabel.ClientID, @"'); function UpdateLabel_", ClientID, @"(content, context) { var lbl = document.getElementById(context); if(lbl) { lbl.innerHTML = content; lbl.className = """"; } }"); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "InvalidLogonAttempts_" + ClientID, sbScript.ToString(), true); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing) { this.rqValue.Visible = false; // Do not process } else { // Set failure text if (this.FailureText != "") { Login1.FailureText = ResHelper.LocalizeString(this.FailureText); } else { Login1.FailureText = GetString("Login_FailureText"); } // Set strings lnkPasswdRetrieval.Text = GetString("LogonForm.lnkPasswordRetrieval"); lblPasswdRetrieval.Text = GetString("LogonForm.lblPasswordRetrieval"); btnPasswdRetrieval.Text = GetString("LogonForm.btnPasswordRetrieval"); rqValue.ErrorMessage = GetString("LogonForm.rqValue"); rqValue.ValidationGroup = ClientID + "_PasswordRetrieval"; // Set logon strings LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblItem != null) { lblItem.Text = "{$LogonForm.UserName$}"; } lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Text = "{$LogonForm.Password$}"; } LocalizedCheckBox chkItem = (LocalizedCheckBox)Login1.FindControl("chkRememberMe"); if (chkItem != null) { chkItem.Text = "{$LogonForm.RememberMe$}"; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.Text = "{$LogonForm.LogOnButton$}"; btnItem.ValidationGroup = ClientID + "_Logon"; } RequiredFieldValidator rfv = (RequiredFieldValidator)Login1.FindControl("rfvUserNameRequired"); if (rfv != null) { rfv.ValidationGroup = ClientID + "_Logon"; rfv.ToolTip = GetString("LogonForm.NameRequired"); } this.lnkPasswdRetrieval.Visible = this.AllowPasswordRetrieval; Login1.LoggedIn += new EventHandler(Login1_LoggedIn); Login1.LoggingIn += new LoginCancelEventHandler(Login1_LoggingIn); btnPasswdRetrieval.Click += new EventHandler(btnPasswdRetrieval_Click); btnPasswdRetrieval.ValidationGroup = ClientID + "_PasswordRetrieval"; if (!RequestHelper.IsPostBack()) { Login1.UserName = ValidationHelper.GetString(Request.QueryString["username"], ""); // Set SkinID properties if (!this.StandAlone && (this.PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(this.Page.StyleSheetTheme, "") == "")) { SetSkinID(this.SkinID); } } if (!this.AllowPasswordRetrieval) { pnlPasswdRetrieval.Visible = false; } } }
/// <summary> /// Sets forgotten password mode. /// </summary> private void SetForgottenPasswordMode() { var txtUserName = (CMSTextBox)Login1.FindControl("UserName"); if (txtUserName != null) { // Clear input field in case pre-filled user name is not a valid email if (!ValidationHelper.IsEmail(txtUserName.Text)) { txtUserName.Text = ""; Login1.UserName = ""; } } var plcPasscodeBox = Login1.FindControl("plcPasscodeBox"); if (plcPasscodeBox != null) { plcPasscodeBox.Visible = false; } var plcLoginInputs = Login1.FindControl("plcLoginInputs"); if (plcLoginInputs != null) { plcLoginInputs.Visible = true; } var divPassword = Login1.FindControl("divPassword"); if (divPassword != null) { divPassword.Visible = false; } var plcRememberMe = Login1.FindControl("plcRememberMe"); if (plcRememberMe != null) { plcRememberMe.Visible = false; } var plcTokenInfo = Login1.FindControl("plcTokenInfo"); if (plcTokenInfo != null) { plcTokenInfo.Visible = false; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.ResourceString = "LogonForm.SendRequest"; btnItem.CommandName = string.Empty; } MainTextResString = "logonform.lnkpasswordretrieval"; LocalizedLabel lblUserName = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.ResourceString = "logonform.lblpasswordretrieval"; } RequiredFieldValidator rfvUserName = (RequiredFieldValidator)Login1.FindControl("rfvUserNameRequired"); if (rfvUserName != null) { rfvUserName.ToolTip = GetString("LogonForm.NameOrEmailRequired"); rfvUserName.Text = rfvUserName.ErrorMessage = GetString("logonform.rqvalue"); } var lnkPassword = Login1.FindControl("lnkPassword") as LocalizedLinkButton; if (lnkPassword != null) { lnkPassword.ResourceString = "LogonForm.BackToLogon"; } IsForgottenPassword = true; }
private void SetDialogMode() { // Check if user can edit the stylesheet CurrentUserInfo currentUser = CMSContext.CurrentUser; string siteName = (CurrentSite != null) ? CurrentSite.SiteName : string.Empty; if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design" }, siteName)) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Properties;Properties.General;General.Design"); } // Hide OK button btnOk.Visible = false; CurrentMaster.PanelContent.CssClass = "PageContent"; CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", EnableViewState = false, CssClass = "SubmitButton" }; btnSave.Click += (sender, e) => Save(false); CurrentMaster.PanelFooter.Controls.Add(btnSave); // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "return CloseDialog();", CssClass = "SubmitButton" }); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // WAI validation lblUserName = (LocalizedLabel)loginElem.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.Text = GetString("general.username"); lblUserName.Attributes.Add("style", "display: none;"); } lblPassword = (LocalizedLabel)loginElem.FindControl("lblPassword"); if (lblPassword != null) { lblPassword.Text = GetString("general.password"); lblPassword.Attributes.Add("style", "display: none;"); } // Set properties for validator rfv = (RequiredFieldValidator)loginElem.FindControl("rfvUserNameRequired"); rfv.ErrorMessage = GetString("edituser.erroremptyusername"); rfv.ToolTip = GetString("edituser.erroremptyusername"); rfv.ValidationGroup = ClientID + "_MiniLogon"; // Set failure text if (!string.IsNullOrEmpty(FailureText)) { loginElem.FailureText = ResHelper.LocalizeString(FailureText); } else { loginElem.FailureText = GetString("Login_FailureText"); } // Set visibility of buttons login = (LocalizedButton)loginElem.FindControl("btnLogon"); if (login != null) { login.Visible = !ShowImageButton; login.ValidationGroup = ClientID + "_MiniLogon"; } loginImg = (ImageButton)loginElem.FindControl("btnImageLogon"); if (loginImg != null) { loginImg.Visible = ShowImageButton; loginImg.ImageUrl = ImageUrl; loginImg.ValidationGroup = ClientID + "_MiniLogon"; } // Ensure display control as inline and is used right default button container = (Panel)loginElem.FindControl("pnlLogonMiniForm"); if (container != null) { container.Attributes.Add("style", "display: inline;"); if (ShowImageButton) { if (loginImg != null) { container.DefaultButton = loginImg.ID; } else if (login != null) { container.DefaultButton = login.ID; } } } if (!string.IsNullOrEmpty(UserNameText)) { // Initialize javascript for focus and blur UserName textbox user = (TextBox)loginElem.FindControl("UserName"); user.Attributes.Add("onfocus", "MLUserFocus_" + ClientID + "('focus');"); user.Attributes.Add("onblur", "MLUserFocus_" + ClientID + "('blur');"); string focusScript = "function MLUserFocus_" + ClientID + "(type)" + "{" + "var userNameBox = document.getElementById('" + user.ClientID + "');" + "if(userNameBox.value == '" + UserNameText + "' && type == 'focus')" + "{userNameBox.value = '';}" + "else if (userNameBox.value == '' && type == 'blur')" + "{userNameBox.value = '" + UserNameText + "';}" + "}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "MLUserNameFocus_" + ClientID, ScriptHelper.GetScript(focusScript)); } loginElem.LoggedIn += loginElem_LoggedIn; loginElem.LoggingIn += loginElem_LoggingIn; loginElem.LoginError += loginElem_LoginError; if (!RequestHelper.IsPostBack()) { // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, string.Empty) == string.Empty)) { SetSkinID(SkinID); } } if (string.IsNullOrEmpty(loginElem.UserName)) { loginElem.UserName = UserNameText; } } }
private void SetDialogButtons() { CurrentMaster.PanelFooter.CssClass = "FloatRight"; // Add save button LocalizedButton btnSave = new LocalizedButton { ID = "btnSave", ResourceString = "general.save", EnableViewState = false, CssClass = "SubmitButton" }; btnSave.Click += (sender, e) => editElem.Save(true); mCurrentMaster.PanelFooter.Controls.Add(btnSave); // Add save & close button LocalizedButton btnSaveAndCancel = new LocalizedButton { ID = "btnSaveCancel", ResourceString = "general.saveandclose", EnableViewState = false, CssClass = "LongSubmitButton" }; btnSaveAndCancel.Click += (sender, e) => { if (editElem.Save(false)) { // Register script for save value to uniselector and close the window UpdateUniSelector(true); } }; mCurrentMaster.PanelFooter.Controls.Add(btnSaveAndCancel); // Add close button every time mCurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "return CloseDialog();", CssClass = "SubmitButton" }); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { rqValue.Visible = false; // Do not process } else { // Set failure text if (FailureText != "") { Login1.FailureText = ResHelper.LocalizeString(FailureText); } else { Login1.FailureText = GetString("Login_FailureText"); } // Set strings lnkPasswdRetrieval.Text = GetString("LogonForm.lnkPasswordRetrieval"); lblPasswdRetrieval.Text = GetString("LogonForm.lblPasswordRetrieval"); btnPasswdRetrieval.Text = GetString("LogonForm.btnPasswordRetrieval"); rqValue.ErrorMessage = GetString("LogonForm.rqValue"); rqValue.ValidationGroup = ClientID + "_PasswordRetrieval"; // Set logon strings LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblItem != null) { lblItem.Text = "{$LogonForm.UserName$}"; } lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Text = "{$LogonForm.Password$}"; } LocalizedCheckBox chkItem = (LocalizedCheckBox)Login1.FindControl("chkRememberMe"); if (chkItem != null) { chkItem.Text = "{$LogonForm.RememberMe$}"; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.Text = "{$LogonForm.LogOnButton$}"; btnItem.ValidationGroup = ClientID + "_Logon"; } RequiredFieldValidator rfv = (RequiredFieldValidator)Login1.FindControl("rfvUserNameRequired"); if (rfv != null) { rfv.ValidationGroup = ClientID + "_Logon"; rfv.ToolTip = GetString("LogonForm.NameRequired"); } CMSTextBox txtUserName = (CMSTextBox)Login1.FindControl("UserName"); if (txtUserName != null) { txtUserName.EnableAutoComplete = SecurityHelper.IsAutoCompleteEnabledForLogin(CMSContext.CurrentSiteName); } lnkPasswdRetrieval.Visible = AllowPasswordRetrieval; Login1.LoggedIn += new EventHandler(Login1_LoggedIn); Login1.LoggingIn += new LoginCancelEventHandler(Login1_LoggingIn); Login1.LoginError += new EventHandler(Login1_LoginError); btnPasswdRetrieval.Click += new EventHandler(btnPasswdRetrieval_Click); btnPasswdRetrieval.ValidationGroup = ClientID + "_PasswordRetrieval"; if (!RequestHelper.IsPostBack()) { Login1.UserName = ValidationHelper.GetString(Request.QueryString["username"], ""); // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, "") == "")) { SetSkinID(SkinID); } } if (!AllowPasswordRetrieval) { pnlPasswdRetrieval.Visible = false; } // Register script to update logon error message LocalizedLabel failureLit = Login1.FindControl("FailureText") as LocalizedLabel; if (failureLit != null) { StringBuilder sbScript = new StringBuilder(); sbScript.Append(@" function UpdateLabel_", ClientID, @"(content, context) { var lbl = document.getElementById(context); if(lbl) { lbl.innerHTML = content; lbl.className = ""InfoLabel""; } }"); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "InvalidLogonAttempts_" + ClientID, sbScript.ToString(), true); } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // WAI validation lblUserName = (LocalizedLabel)loginElem.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.Text = GetString("general.username"); if (!ShowUserNameLabel) { lblUserName.Attributes.Add("style", "display: none;"); } } lblPassword = (LocalizedLabel)loginElem.FindControl("lblPassword"); if (lblPassword != null) { lblPassword.Text = GetString("general.password"); if (!ShowPasswordLabel) { lblPassword.Attributes.Add("style", "display: none;"); } } // Set properties for validator rfv = (RequiredFieldValidator)loginElem.FindControl("rfvUserNameRequired"); rfv.ToolTip = GetString("LogonForm.NameRequired"); rfv.Text = rfv.ErrorMessage = GetString("LogonForm.EnterName"); rfv.ValidationGroup = ClientID + "_MiniLogon"; // Set visibility of buttons login = (LocalizedButton)loginElem.FindControl("btnLogon"); if (login != null) { login.Visible = !ShowImageButton; login.ValidationGroup = ClientID + "_MiniLogon"; } loginImg = (ImageButton)loginElem.FindControl("btnImageLogon"); if (loginImg != null) { loginImg.Visible = ShowImageButton; loginImg.ImageUrl = ImageUrl; loginImg.ValidationGroup = ClientID + "_MiniLogon"; } // Ensure display control as inline and is used right default button container = (Panel)loginElem.FindControl("pnlLogonMiniForm"); if (container != null) { container.Attributes.Add("style", "display: inline;"); if (ShowImageButton) { if (loginImg != null) { container.DefaultButton = loginImg.ID; } else if (login != null) { container.DefaultButton = login.ID; } } } CMSTextBox txtUserName = (CMSTextBox)loginElem.FindControl("UserName"); if (txtUserName != null) { txtUserName.EnableAutoComplete = SecurityHelper.IsAutoCompleteEnabledForLogin(SiteContext.CurrentSiteName); } if (!string.IsNullOrEmpty(UserNameText)) { // Initialize javascript for focus and blur UserName textbox user = (TextBox)loginElem.FindControl("UserName"); user.Attributes.Add("onfocus", "MLUserFocus_" + ClientID + "('focus');"); user.Attributes.Add("onblur", "MLUserFocus_" + ClientID + "('blur');"); string focusScript = "function MLUserFocus_" + ClientID + "(type)" + "{" + "var userNameBox = document.getElementById('" + user.ClientID + "');" + "if(userNameBox.value == '" + UserNameText + "' && type == 'focus')" + "{userNameBox.value = '';}" + "else if (userNameBox.value == '' && type == 'blur')" + "{userNameBox.value = '" + UserNameText + "';}" + "}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "MLUserNameFocus_" + ClientID, ScriptHelper.GetScript(focusScript)); } loginElem.LoggedIn += loginElem_LoggedIn; loginElem.LoggingIn += loginElem_LoggingIn; loginElem.LoginError += loginElem_LoginError; loginElem.Authenticate += loginElem_Authenticate; if (!RequestHelper.IsPostBack()) { // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, string.Empty) == string.Empty)) { SetSkinID(SkinID); } } if (string.IsNullOrEmpty(loginElem.UserName)) { loginElem.UserName = UserNameText; } // Register script to update logon error message LocalizedLabel failureLit = loginElem.FindControl("FailureText") as LocalizedLabel; if (failureLit != null) { StringBuilder sbScript = new StringBuilder(); sbScript.Append(@" function UpdateLabel_", ClientID, @"(content, context) { var lbl = document.getElementById(context); if(lbl) { lbl.innerHTML = content; lbl.className = ""InfoLabel""; } }"); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "InvalidLogonAttempts_" + ClientID, sbScript.ToString(), true); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Setup the page variables templateId = QueryHelper.GetInteger("templateid", 0); deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0); if (deviceProfileId > 0) { // Display device profile label showNewDeviceSelector = false; DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceLayout != null) { lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>"; } } else { // Display device profile selector pnlNewDevice.Visible = true; lblNewDevice.Visible = false; } // Setup the page title CurrentMaster.Title.TitleText = GetString("devicelayout.new"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_DeviceProfile/new.png"); CurrentMaster.Title.HelpTopicName = "CMS_Design_page_device_layout"; CurrentMaster.Title.HelpName = "helpTopic"; // Source device profile selector ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")"; ucDeviceProfile.SpecialFields = new string[, ] { { GetString("devicelayout.defaultdeviceprofile"), "0" } }; // New device profile selector // Do not display profiles which have layout already defined ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))"; ucNewDeviceProfile.OrderBy = "ProfileOrder"; ucNewDeviceProfile.SpecialFields = new string[, ] { { GetString("devicelayout.selectdeviceprofile"), "" } }; ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(this.value.length > 0);"; // Javascript rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)"); rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)"); rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)"); if (!RequestHelper.IsPostBack()) { rbtnDevice.Checked = true; } // Register the page javascript string script = @" function EnableSelection(enabled) { var pnlContent = jQuery('#" + pnlContent.ClientID + @" :input'); if (enabled) { pnlContent.removeAttr('disabled'); var rbtnDevice = jQuery('#" + rbtnDevice.ClientID + @"'); var rbtnLayout = jQuery('#" + rbtnLayout.ClientID + @"'); var pnlLayout = jQuery('#" + pnlLayout.ClientID + @" :input'); var pnlDevice = jQuery('#" + pnlDevice.ClientID + @" :input'); if (rbtnDevice.is(':checked')) { pnlLayout.attr('disabled', 'disabled'); } else if (rbtnLayout.is(':checked')) { pnlDevice.attr('disabled', 'disabled'); } else { pnlLayout.attr('disabled', 'disabled'); pnlDevice.attr('disabled', 'disabled'); } } else { pnlContent.attr('disabled', 'disabled'); } jQuery('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled'); } jQuery(document).ready(function () { EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @"); });"; ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true); ScriptHelper.RegisterJQuery(Page); // Empty footer container if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Clear(); } // Add the Cancel button to the footer panel LocalizedButton btnOk = new LocalizedButton { ID = "btnOk", ResourceString = "general.ok", CssClass = "SubmitButton", }; btnOk.Click += new EventHandler(SaveAction); // Add the Cancel button to the footer panel LocalizedButton btnCancel = new LocalizedButton { ID = "btnCancel", ResourceString = "general.cancel", CssClass = "SubmitButton", OnClientClick = "CloseDialog(); return false;" }; // Button container panel Panel pnlRight = new Panel { ID = "pnlRight", CssClass = "TextRight" }; pnlRight.Controls.Add(btnOk); pnlRight.Controls.Add(btnCancel); // Add the Ok, Cancel buttons to the footer controls collection if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Add(pnlRight); } }
protected void Page_Load(object sender, EventArgs e) { SetBrowserClass(); AddNoCacheTag(); // Ensure the refresh script bool sameWindow = (FormStateHelper.PreservePostbackValuesOnLogin && (FormStateHelper.GetSavedState() != null)); string defaultCondition = "((top.frames['cmsheader'] != null) || (top.frames['propheader'] != null))"; if (sameWindow) { ScriptHelper.RegisterStartupScript(this, typeof(string), "TopWindow", ScriptHelper.GetScript("if (((document.body.clientWidth < 510) || (document.body.clientHeight < 300)) && " + defaultCondition + ") { var loginUrl = top.window.location.href.replace(/\\/\\(\\w\\([^\\)]+\\)\\)/g, ''); if (loginUrl.indexOf('restorepost=0') < 0) { if (loginUrl.indexOf('?') >= 0) { loginUrl = loginUrl + '&restorepost=0'; } else { loginUrl = loginUrl + '?restorepost=0'; } } top.window.location.replace(loginUrl); }")); } else { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "TopWindow", ScriptHelper.GetScript("if " + defaultCondition + " { top.window.location.replace(top.window.location.href.replace(/\\/\\(\\w\\([^\\)]+\\)\\)/g, '')); }")); } // Enable caps lock check if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSUseCapsLockNotification"], true)) { RegisterCAPSLOCKScript(); TextBox txtPassword = (TextBox)Login1.FindControl("Password"); if (txtPassword != null) { txtPassword.Attributes.Add("onkeypress", "CheckCapsLock(event)"); } } // Site manager prefix string smPrefix = IsSiteManager ? "SM/" : null; // Initialize help CMSAdminControls_UI_PageElements_Help ucHelp = (CMSAdminControls_UI_PageElements_Help)Login1.FindControl("ucHelp"); ucHelp.Tooltip = GetString("logon.helptooltip"); ucHelp.IconUrl = GetImageUrl("Others/LogonForm/" + smPrefix + "HelpButton.png"); ucHelp.TopicName = "LogonTroubleshooting"; LocalizedLabel lblItem = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lblItem != null) { lblItem.Text = "{$LogonForm.UserName$}"; } lblItem = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lblItem != null) { lblItem.Text = "{$LogonForm.Password$}"; } // Display culture link due to value of the key stored in the web.config file bool showCultureSelector = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSShowLogonCultureSelector"], true); if (showCultureSelector) { ImageButton lnkLanguage = (ImageButton)Login1.FindControl("lnkLanguage"); if (lnkLanguage != null) { lnkLanguage.Visible = true; // Ensure language selection panel functionality HtmlGenericControl pnlLanguage = (HtmlGenericControl)Login1.FindControl("pnlLanguage"); if (pnlLanguage != null) { lnkLanguage.ImageUrl = GetImageUrl("Others/LogonForm/" + smPrefix + "LanguageButton.png"); lnkLanguage.AlternateText = GetString("LogonForm.SelectLanguage"); lnkLanguage.ToolTip = GetString("LogonForm.SelectLanguage"); this.ltlScript.Text = ScriptHelper.GetScript("function ShowLanguage(id){var panel=document.getElementById(id);if(panel!=null){panel.style.display=(panel.style.display == 'block')?'none':'block';}}"); lnkLanguage.Attributes.Add("onclick", "ShowLanguage('" + pnlLanguage.ClientID + "'); return false;"); } } } // Set up forgotten password link if (ShowForgottenPassword) { ImageButton lnkPassword = (ImageButton)Login1.FindControl("lnkPassword"); if (lnkPassword != null) { lnkPassword.Visible = true; lnkPassword.ImageUrl = GetImageUrl("Others/LogonForm/" + smPrefix + "ForgottenPassword.png"); lnkPassword.AlternateText = GetString("LogonForm.ForgottenPassword"); lnkPassword.ToolTip = GetString("LogonForm.ForgottenPassword"); lnkPassword.Click += new ImageClickEventHandler(lnkPassword_Click); } } LocalizedCheckBox chkItem = (LocalizedCheckBox)Login1.FindControl("chkRememberMe"); if (chkItem != null) { chkItem.Text = "{$LogonForm.RememberMe$}"; } LocalizedButton btnItem = (LocalizedButton)Login1.FindControl("LoginButton"); if (btnItem != null) { btnItem.Text = "{$LogonForm.LogOnButton$}"; btnItem.Click += new EventHandler(btnItem_Click); } RequiredFieldValidator rfvUserName = (RequiredFieldValidator)Login1.FindControl("rfvUserNameRequired"); if (rfvUserName != null) { rfvUserName.ToolTip = GetString("LogonForm.NameRequired"); rfvUserName.ErrorMessage = GetString("LogonForm.NameRequired"); } // Load UI cultures for the dropdown list if (!RequestHelper.IsPostBack()) { LoadCultures(); } Label lblVersion = (Label)this.FindControl("lblVersion"); if (lblVersion != null) { // Show version only if right key is inserted string versionKey = QueryHelper.GetString("versionkey", string.Empty); if (EncryptionHelper.VerifyVersionRSA(versionKey)) { lblVersion.Text = ResHelper.GetString("Footer.Version") + " " + CMSContext.GetFriendlySystemVersion(true); } } Login1.LoggingIn += new LoginCancelEventHandler(Login1_LoggingIn); Login1.LoggedIn += new EventHandler(Login1_LoggedIn); Login1.LoginError += new EventHandler(Login1_LoginError); if (!RequestHelper.IsPostBack()) { Login1.UserName = QueryHelper.GetString("username", String.Empty); } // Ensure username textbox focus TextBox txtUserName = (TextBox)Login1.FindControl("UserName"); if (txtUserName != null) { ScriptHelper.RegisterStartupScript(this, GetType(), "SetFocus", ScriptHelper.GetScript("var txt=document.getElementById('" + txtUserName.ClientID + "');if(txt!=null){txt.focus();}")); } // Ensure different class for Site Manager if (IsSiteManager) { pnlMainContainer.CssClass += " SM"; } if (QueryHelper.GetBoolean("forgottenpassword", false)) { SetForgottenPasswordMode(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Setup the page variables templateId = QueryHelper.GetInteger("templateid", 0); deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0); if (deviceProfileId > 0) { // Display device profile label showNewDeviceSelector = false; DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId); if (deviceLayout != null) { lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>"; } } else { // Display device profile selector pnlNewDevice.Visible = true; lblNewDevice.Visible = false; } // Setup the page title CurrentMaster.Title.TitleText = GetString("devicelayout.new"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_DeviceProfile/new.png"); CurrentMaster.Title.HelpTopicName = "CMS_Design_page_device_layout"; CurrentMaster.Title.HelpName = "helpTopic"; // Source device profile selector ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")"; ucDeviceProfile.SpecialFields = new string[,] { { GetString("devicelayout.defaultdeviceprofile"), "0" } }; // New device profile selector // Do not display profiles which have layout already defined ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))"; ucNewDeviceProfile.OrderBy = "ProfileOrder"; ucNewDeviceProfile.SpecialFields = new string[,] { { GetString("devicelayout.selectdeviceprofile"), "" } }; ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(this.value.length > 0);"; // Javascript rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)"); rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)"); rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)"); if (!RequestHelper.IsPostBack()) { rbtnDevice.Checked = true; } // Register the page javascript string script = @" function EnableSelection(enabled) { var pnlContent = jQuery('#" + pnlContent.ClientID + @" :input'); if (enabled) { pnlContent.removeAttr('disabled'); var rbtnDevice = jQuery('#" + rbtnDevice.ClientID + @"'); var rbtnLayout = jQuery('#" + rbtnLayout.ClientID + @"'); var pnlLayout = jQuery('#" + pnlLayout.ClientID + @" :input'); var pnlDevice = jQuery('#" + pnlDevice.ClientID + @" :input'); if (rbtnDevice.is(':checked')) { pnlLayout.attr('disabled', 'disabled'); } else if (rbtnLayout.is(':checked')) { pnlDevice.attr('disabled', 'disabled'); } else { pnlLayout.attr('disabled', 'disabled'); pnlDevice.attr('disabled', 'disabled'); } } else { pnlContent.attr('disabled', 'disabled'); } jQuery('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled'); } jQuery(document).ready(function () { EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @"); });"; ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true); ScriptHelper.RegisterJQuery(Page); // Empty footer container if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Clear(); } // Add the Cancel button to the footer panel LocalizedButton btnOk = new LocalizedButton { ID = "btnOk", ResourceString = "general.ok", CssClass = "SubmitButton", }; btnOk.Click += new EventHandler(SaveAction); // Add the Cancel button to the footer panel LocalizedButton btnCancel = new LocalizedButton { ID = "btnCancel", ResourceString = "general.cancel", CssClass = "SubmitButton", OnClientClick = "CloseDialog(); return false;" }; // Button container panel Panel pnlRight = new Panel { ID = "pnlRight", CssClass = "TextRight" }; pnlRight.Controls.Add(btnOk); pnlRight.Controls.Add(btnCancel); // Add the Ok, Cancel buttons to the footer controls collection if (CurrentMaster.PanelFooter != null) { CurrentMaster.PanelFooter.Controls.Add(pnlRight); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // WAI validation lblUserName = (LocalizedLabel)loginElem.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.Text = GetString("general.username"); if (!ShowUserNameLabel) { lblUserName.Attributes.Add("style", "display: none;"); } } lblPassword = (LocalizedLabel)loginElem.FindControl("lblPassword"); if (lblPassword != null) { lblPassword.Text = GetString("general.password"); if (!ShowPasswordLabel) { lblPassword.Attributes.Add("style", "display: none;"); } } // Set properties for validator rfv = (RequiredFieldValidator)loginElem.FindControl("rfvUserNameRequired"); rfv.ErrorMessage = GetString("edituser.erroremptyusername"); rfv.ToolTip = GetString("edituser.erroremptyusername"); rfv.ValidationGroup = ClientID + "_MiniLogon"; // Set failure text if (!string.IsNullOrEmpty(FailureText)) { loginElem.FailureText = ResHelper.LocalizeString(FailureText); } else { loginElem.FailureText = GetString("Login_FailureText"); } // Set visibility of buttons login = (LocalizedButton)loginElem.FindControl("btnLogon"); if (login != null) { login.Visible = !ShowImageButton; login.ValidationGroup = ClientID + "_MiniLogon"; } loginImg = (ImageButton)loginElem.FindControl("btnImageLogon"); if (loginImg != null) { loginImg.Visible = ShowImageButton; loginImg.ImageUrl = ImageUrl; loginImg.ValidationGroup = ClientID + "_MiniLogon"; } // Ensure display control as inline and is used right default button container = (Panel)loginElem.FindControl("pnlLogonMiniForm"); if (container != null) { container.Attributes.Add("style", "display: inline;"); if (ShowImageButton) { if (loginImg != null) { container.DefaultButton = loginImg.ID; } else if (login != null) { container.DefaultButton = login.ID; } } } CMSTextBox txtUserName = (CMSTextBox)loginElem.FindControl("UserName"); if (txtUserName != null) { txtUserName.EnableAutoComplete = SecurityHelper.IsAutoCompleteEnabledForLogin(CMSContext.CurrentSiteName); } if (!string.IsNullOrEmpty(UserNameText)) { // Initialize javascript for focus and blur UserName textbox user = (TextBox)loginElem.FindControl("UserName"); user.Attributes.Add("onfocus", "MLUserFocus_" + ClientID + "('focus');"); user.Attributes.Add("onblur", "MLUserFocus_" + ClientID + "('blur');"); string focusScript = "function MLUserFocus_" + ClientID + "(type)" + "{" + "var userNameBox = document.getElementById('" + user.ClientID + "');" + "if(userNameBox.value == '" + UserNameText + "' && type == 'focus')" + "{userNameBox.value = '';}" + "else if (userNameBox.value == '' && type == 'blur')" + "{userNameBox.value = '" + UserNameText + "';}" + "}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "MLUserNameFocus_" + ClientID, ScriptHelper.GetScript(focusScript)); } loginElem.LoggedIn += loginElem_LoggedIn; loginElem.LoggingIn += loginElem_LoggingIn; loginElem.LoginError += loginElem_LoginError; if (!RequestHelper.IsPostBack()) { // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, string.Empty) == string.Empty)) { SetSkinID(SkinID); } } if (string.IsNullOrEmpty(loginElem.UserName)) { loginElem.UserName = UserNameText; } // Register script to update logon error message Label failureLit = loginElem.FindControl("FailureText") as Label; if (failureLit != null) { StringBuilder sbScript = new StringBuilder(); sbScript.Append(@" function UpdateLabel_", ClientID, @"(content, context) { var lbl = document.getElementById(context); if(lbl) { lbl.innerHTML = content; lbl.className = ""InfoLabel""; } }"); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "InvalidLogonAttempts_" + ClientID, sbScript.ToString(), true); } } }
private void SetDialogMode() { // When in modal dialog, the margins have to be increased CurrentMaster.PanelContent.CssClass = "PageContent"; CurrentMaster.PanelFooter.CssClass = "FloatRight"; btnOk.ResourceString = GetString("general.save"); btnOk.Parent.Controls.Remove(btnOk); // Add save button CurrentMaster.PanelFooter.Controls.Add(btnOk); // Add save & close button LocalizedButton btnSaveAndClose = new LocalizedButton { ID = "btnSaveAndClose", ResourceString = "general.saveandclose", CssClass = "LongSubmitButton", EnableViewState = false }; btnSaveAndClose.Click += (sender, e) => Save(true); CurrentMaster.PanelFooter.Controls.Add(btnSaveAndClose); // Add close button CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton { ID = "btnCancel", ResourceString = "general.close", EnableViewState = false, OnClientClick = "return CloseDialog();", CssClass = "SubmitButton" }); // When in modal dialog, the window scrolls to bottom, so this hack will scroll it back to top string scrollScript = "var scrollerDiv = document.getElementById('divContent'); if (scrollerDiv != null) setTimeout(function() { scrollerDiv.scrollTop = 0; }, 500);"; ScriptHelper.RegisterStartupScript(this, GetType(), "ScrollTop", scrollScript, true); }