Esempio n. 1
0
        protected override void OnInit(EventArgs e)
        {
            JavaScript.RequestRegistration(CommonJs.DnnPlugins);
            ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);

            if (AJAX.IsEnabled())
            {
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(UpdateParameterButton);
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(UpdateButton);
            }
        }
Esempio n. 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                var objHTML = new HtmlTextController();

                // edit in place
                if (EditorEnabled && IsEditable && PortalSettings.UserMode == PortalSettings.Mode.Edit)
                {
                    EditorEnabled = true;
                }
                else
                {
                    EditorEnabled = false;
                }

                // get content
                HtmlTextInfo htmlTextInfo  = null;
                string       contentString = "";

                htmlTextInfo = objHTML.GetTopHtmlText(ModuleId, !IsEditable, WorkflowID);

                if ((htmlTextInfo != null))
                {
                    //don't decode yet (this is done in FormatHtmlText)
                    contentString = htmlTextInfo.Content;
                }
                else
                {
                    // get default content from resource file
                    if (PortalSettings.UserMode == PortalSettings.Mode.Edit)
                    {
                        if (EditorEnabled)
                        {
                            contentString = Localization.GetString("AddContentFromToolBar.Text", LocalResourceFile);
                        }
                        else
                        {
                            contentString = Localization.GetString("AddContentFromActionMenu.Text", LocalResourceFile);
                        }
                    }
                    else
                    {
                        // hide the module if no content and in view mode
                        ContainerControl.Visible = false;
                    }
                }

                // token replace
                EditorEnabled = EditorEnabled && !Settings.ReplaceTokens;

                // localize toolbar
                if (EditorEnabled)
                {
                    foreach (DNNToolBarButton button in editorDnnToobar.Buttons)
                    {
                        button.ToolTip = Localization.GetString(button.ToolTip + ".ToolTip", LocalResourceFile);
                    }
                }
                else
                {
                    editorDnnToobar.Visible = false;
                }

                lblContent.EditEnabled = EditorEnabled;

                // add content to module
                lblContent.Controls.Add(new LiteralControl(HtmlTextController.FormatHtmlText(ModuleId, contentString, Settings, PortalSettings, Page)));

                //set normalCheckBox on the content wrapper to prevent form decoration if its disabled.
                if (!Settings.UseDecorate)
                {
                    lblContent.CssClass = string.Format("{0} normalCheckBox", lblContent.CssClass);
                }

                if (IsPostBack && AJAX.IsEnabled() && AJAX.GetScriptManager(Page).IsInAsyncPostBack)
                {
                    var resetScript = $@"
if(typeof dnn !== 'undefined' && typeof dnn.controls !== 'undefined' && typeof dnn.controls.controls !== 'undefined'){{
    var control = dnn.controls.controls['{lblContent.ClientID}'];
    if(control && control.container !== $get('{lblContent.ClientID}')){{
        dnn.controls.controls['{lblContent.ClientID}'] = null;
    }}
}};";
                    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), $"ResetHtmlModule{ClientID}", resetScript, true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }