/// <summary> /// Registers the linked files /// </summary> private void RegisterLinkedFiles() { // Create linked JS file if (LinkedFile.Trim() != string.Empty) { string linkedFile = String.Empty; // Register some script files manually, to prevent multiple registration switch (LinkedFile.Trim().ToLowerCSafe()) { case "jquery": if (ScriptHelper.RequestScriptRegistration(ScriptHelper.JQUERY_KEY)) { linkedFile = ScriptHelper.JQUERY_FILENAME; } break; case "prototype": if (ScriptHelper.RequestScriptRegistration(ScriptHelper.PROTOTYPE_KEY)) { linkedFile = ScriptHelper.PROTOTYPE_FILENAME; } break; case "mootools": if (ScriptHelper.RequestScriptRegistration(ScriptHelper.MOOTOOLS_KEY)) { linkedFile = ScriptHelper.MOOTOOLS_FILENAME; } break; case "silverlight": if (ScriptHelper.RequestScriptRegistration(ScriptHelper.SILVERLIGHT_KEY)) { linkedFile = ScriptHelper.SILVERLIGHT_FILENAME; } break; default: { // File URL string file = LinkedFile; string key = ScriptHelper.SCRIPTFILE_PREFIX_KEY + file; if (ScriptHelper.RequestScriptRegistration(key)) { linkedFile = ScriptHelper.GetScriptUrl(file, false); linkedFile = ResolveUrl(linkedFile); } } break; } if (!String.IsNullOrEmpty(linkedFile)) { string script = ScriptHelper.GetIncludeScript(linkedFile); // Switch for script position on the page switch (LinkedFilePageLocation.ToLowerCSafe()) { case "beginning": ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "script", script); break; case "startup": ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", script); break; case "header": default: Page.Header.Controls.Add(new LiteralControl(script)); break; } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Include javascript only in live site or preview mode if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) || (CMSContext.ViewMode == ViewModeEnum.Preview)) { // Render the inline script if (InlineScript.Trim() != string.Empty) { string inlineScript = InlineScript; // Check if script tags must be generated if (GenerateScriptTags && (InlineScriptPageLocation.ToLower() != "submit")) { inlineScript = ScriptHelper.GetScript(InlineScript); } // Switch for script position on the page switch (InlineScriptPageLocation.ToLower()) { case "header": Page.Header.Controls.Add(new LiteralControl(inlineScript)); break; case "beginning": ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "inlinescript", inlineScript); break; case "inline": ltlInlineScript.Text = inlineScript; break; case "startup": ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "inlinescript", inlineScript); break; case "submit": ScriptHelper.RegisterOnSubmitStatement(Page, typeof(string), ClientID + "inlinescript", inlineScript); break; default: ltlInlineScript.Text = inlineScript; break; } } // Create linked js file if (LinkedFile.Trim() != string.Empty) { string linkedFile = ScriptHelper.GetIncludeScript(ResolveUrl(LinkedFile)); // Switch for script position on the page switch (LinkedFilePageLocation.ToLower()) { case "header": Page.Header.Controls.Add(new LiteralControl(linkedFile)); break; case "beginning": ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "script", linkedFile); break; case "startup": ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", linkedFile); break; default: Page.Header.Controls.Add(new LiteralControl(linkedFile)); break; } } } } }