/// <summary> /// Sets buttons actions. /// </summary> protected void Initialize() { ScriptHelper.RegisterDialogScript(Page); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GetSelectedItem" + ItemType, ScriptHelper.GetScript(@" function getSelectedItem_" + ItemType + @"() { if (document.getElementById('" + brsItems.UniSelectorClientID + @"') != null) { return document.getElementById('" + brsItems.UniSelectorClientID + @"').value; } return 0; } function DeleteItem_" + ItemType + @"() { if ((document.getElementById('" + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { if (confirm(" + ScriptHelper.GetLocalizedString("general.confirmdelete") + @")) { document.getElementById('" + hdnItemId.ClientID + @"').value = getSelectedItem_" + ItemType + @"(); " + Page.ClientScript.GetPostBackEventReference(btnHdnDelete, null) + @" } } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); } } function InserMacro_" + ItemType + @"() { if ((document.getElementById('" + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { PageMethods.GetReportItemName('" + ReportInfoProvider.ReportItemTypeToString(ItemType) + "',getSelectedItem_" + ItemType + "(),OnComplete_" + ItemType + @"); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); } } function OnComplete_" + ItemType + @"(result, response, context) { InsertHTML('%%control:Report" + ItemType + "?" + Report.ReportName + @".' + result +'%%'); } function CloneItem_" + ItemType + @"(id) { if ((document.getElementById('" + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { modalDialog('" + UrlResolver.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?objectType=" + GetObjectType() + @"&objectId=' + id") + @", 'CloneObject', 750, 470); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); } }")); const string MODAL_HEIGHT = "'85%'"; const string MODAL_WIDTH = "950"; if (Report != null) { string baseUrl = URLHelper.AddParameterToUrl(ResolveUrl(EditUrl), "reportId", Report.ReportID.ToString()); string fullUrl = ApplicationUrlHelper.AppendDialogHash(baseUrl); btnAdd.Actions.Add(new CMSButtonAction() { OnClientClick = "modalDialog('" + fullUrl + "','ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + ");return false;", Text = GetString("general.new") }); fullUrl = URLHelper.AddParameterToUrl(baseUrl, "preview", "true"); fullUrl = ApplicationUrlHelper.AppendDialogHash(fullUrl); btnAdd.Actions.Add(new CMSButtonAction() { OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;", Text = GetString("general.preview") }); fullUrl = ApplicationUrlHelper.AppendDialogHash(baseUrl); btnAdd.Actions.Add(new CMSButtonAction() { OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;", Text = GetString("general.edit") }); btnAdd.Actions.Add(new CMSButtonAction() { OnClientClick = "DeleteItem_" + ItemType + "(); return false;", Text = GetString("general.delete") }); btnAdd.Actions.Add(new CMSButtonAction() { OnClientClick = "CloneItem_" + ItemType + @"(getSelectedItem_" + ItemType + "()); return false;", Text = GetString("general.clone") }); btnInsert.OnClientClick = "InserMacro_" + ItemType + "(); return false;"; } }
/// <summary> /// Sets buttons actions. /// </summary> protected void Initialize() { ScriptHelper.RegisterDialogScript(Page); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GetSelectedItem" + ItemType.ToString(), ScriptHelper.GetScript(@" function getSelectedItem_" + ItemType.ToString() + "() { \n" + " if (document.getElementById('" + brsItems.UniSelectorClientID + "') != null) { \n" + " return document.getElementById('" + brsItems.UniSelectorClientID + "').value; " + " } \n" + " return 0; } \n\n" + "function DeleteItem_" + ItemType.ToString() + "() { \n" + " if ((document.getElementById('" + brsItems.UniSelectorClientID + "') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + "').value != '0')) { \n" + " if (confirm(" + ScriptHelper.GetString(ResHelper.GetString("general.confirmdelete")) + ")) { \n" + " document.getElementById('" + hdnItemId.ClientID + "').value = getSelectedItem_" + ItemType.ToString() + "(); " + Page.ClientScript.GetPostBackEventReference(btnHdnDelete, null) + " } \n" + " } else { alert(" + ScriptHelper.GetString(ResHelper.GetString("Reporting_General.SelectObjectFirst")) + "); } \n" + "} \n\n" + "function InserMacro_" + ItemType.ToString() + "() { \n" + " if ((document.getElementById('" + brsItems.UniSelectorClientID + "') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + "').value != '0')) { \n" + " PageMethods.GetReportItemName('" + ReportInfoProvider.ReportItemTypeToString(ItemType) + "',getSelectedItem_" + ItemType.ToString() + "(),OnComplete_" + ItemType.ToString() + ");\n" + " } else { alert(" + ScriptHelper.GetString(ResHelper.GetString("Reporting_General.SelectObjectFirst")) + "); } \n" + @"} function OnComplete_" + ItemType.ToString() + @"(result, response, context){ InsertHTML('%%control:Report" + ItemType.ToString() + "?" + Report.ReportName + @".' + result +'%%'); } function CloneItem_" + ItemType.ToString() + @"(id){ if ((document.getElementById('" + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { modalDialog('" + URLHelper.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?objectType=" + GetObjectType() + @"&objectId='+id") + @", 'CloneObject', 750, 400); } else { alert(" + ScriptHelper.GetString(ResHelper.GetString("Reporting_General.SelectObjectFirst")) + @"); } }")); string modalHeight = "760"; string modalWidth = "1050"; if (Report != null) { btnAdd.OnClientClick = "modalDialog('" + ResolveUrl(mEditUrl) + "?reportId=" + Report.ReportID + "','ReportItemEdit'," + modalWidth + "," + modalHeight + ");return false;"; btnEdit.OnClientClick = "if (getSelectedItem_" + ItemType.ToString() + "() != '0') { modalDialog('" + ResolveUrl(mEditUrl) + "?reportId=" + Report.ReportID + "&itemid='+ getSelectedItem_" + ItemType.ToString() + "(),'ReportItemEdit'," + modalWidth + "," + modalHeight + "); } else { alert(" + ScriptHelper.GetString(ResHelper.GetString("Reporting_General.SelectObjectFirst")) + ");} return false;"; btnDelete.OnClientClick = "DeleteItem_" + ItemType.ToString() + "(); return false;"; btnInsert.OnClientClick = "InserMacro_" + mItemType.ToString() + "(); return false;"; btnClone.OnClientClick = "CloneItem_" + ItemType.ToString() + @"(getSelectedItem_" + ItemType.ToString() + "()); return false;"; btnPreview.OnClientClick = "if (getSelectedItem_" + ItemType.ToString() + "() != '0') { modalDialog('" + ResolveUrl(mEditUrl) + "?preview=true&reportId=" + Report.ReportID + "&itemid='+ getSelectedItem_" + ItemType.ToString() + "(),'ReportItemEdit'," + modalWidth + "," + modalHeight + "); } else { alert(" + ScriptHelper.GetString(ResHelper.GetString("Reporting_General.SelectObjectFirst")) + ");} return false;"; } }