Assembly: EPiServer (in EPiServer.dll) Version: 6.0.530.0
Syntax
| C# |
|---|
public class EditPage : SimplePage |
Remarks
As TemplatePage inherits from EditPage, any
attributes or methods defined for EditPage will be available for TemplatePage.
CopyC#
#region Copyright � 1997-2008 EPiServer AB. All Rights Reserved. /* This code may only be used according to the EPiServer License Agreement. The use of this code outside the EPiServer environment, in whole or in parts, is forbidden without prior written permission from EPiServer AB. EPiServer is a registered trademark of EPiServer AB. For more information see http://www.episerver.com/license or request a copy of the EPiServer License Agreement by sending an email to info@episerver.com*/ #endregion using System; using System.Collections.Specialized; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using EPiServer.Core; using EPiServer.DataAccess; using EPiServer.DataAbstraction; using EPiServer.Security; using EPiServer.Web; using EPiServer.Web.PageExtensions; using EPiServer.Web.WebControls; namespace EPiServer { /// <summary> /// <img src="Icons/CSharp.gif" alt="Source included" border="0" /> /// Base class for EPiServer pages that needs to register javascripts and/or CSS files. /// </summary> /// <remarks> /// As <see cref="T:EPiServer.TemplatePage"/> inherits from <b>EditPage</b>, any /// attributes or methods defined for <b>EditPage</b> will be available for <b>TemplatePage</b>. /// <code source="../EPiServerNET/EditPage.cs" lang="cs"/> /// </remarks> /// <seealso cref="N:EPiServer"/> public class EditPage : SimplePage { private StringDictionary _registeredScripts = new StringDictionary(); private StringDictionary _registeredCssScripts = new StringDictionary(); /// <summary> /// Supports the internal infrastructure. Used to indicate that we are in the /// process of creating a new page rather than editing an existing page. /// </summary> public EditPage() : this(0, 0) { } /// <summary> /// Initializes a new instance of the <see cref="EditPage"/> class. /// </summary> /// <param name="options">The page options to enable.</param> /// <remarks> /// The options parameter is a bitmap constructed from the OptionFlag of Page plugin classes from /// the EPiServer.Web.PageExtensions namespace. /// </remarks> public EditPage(int options) : base(options) { } /// <summary> /// Initializes a new instance of the <see cref="EditPage"/> class. /// </summary> /// <param name="enable">The enable.</param> /// <param name="disable">The disable.</param> public EditPage(int enable, int disable) : base(enable, disable) { } /// <summary> /// Registers a css file in the header of the html document. /// </summary> /// <param name="path">The path to the css file</param> /// <returns><b>True</b> if the css file has been registrered or already is registered. /// <b>False</b> if no header node is found in the document.</returns> /// <remarks> /// The CSS file is shows up in a LINK element on the page when the page is rendered. /// Behind the scenes, the provided CSS path is used as a key for the registration. /// </remarks> /// <example> /// A sample CSS file registration on a site residing in the virtual directory "EPiServerSample/". /// <code source="../codesamples/EPiServer/EditPageSamples.cs" region="CssRegistration" lang="cs" /> /// </example> public bool RegisterCssFile(string path) { if (Header == null) { return false; } if (_registeredCssScripts[path] != null) { return true; } // Create Link HTML server control HtmlGenericControl link = new HtmlGenericControl("link"); link.Attributes["rel"] = "stylesheet"; link.Attributes["type"] = "text/css"; link.Attributes["href"] = ResolveUrl(path); // Add the CSS link to the collection Header.Controls.Add(link); // Insert the path as key in the Dictionary, it means the CSS path is registered. _registeredCssScripts[path] = "true"; return true; } /// <summary> /// Determines if the client startup script is registered with the <see cref="EditPage"/> object. /// </summary> /// <param name="path">The path to the css file</param> /// <returns>True if the css file is registered; otherwise, false.</returns> public bool IsCssFileRegistered(string path) { return _registeredCssScripts[path] != null; } /// <summary> /// Registers a script file in the header of the html document. /// </summary> /// <param name="path">The path to the script file</param> /// <returns>True if the script file has been registrered or already is registered. /// False if no header node is found in the document.</returns> public bool RegisterScriptFile(string path) { if (Header == null) { return false; } if (_registeredScripts[path] != null) { return true; } string language = string.Empty; if (path.EndsWith(".js", StringComparison.OrdinalIgnoreCase)) { language = "javascript"; } else if (path.EndsWith(".vbs", StringComparison.OrdinalIgnoreCase)) { language = "vbscript"; } // Create Script HTML server control HtmlGenericControl script = new HtmlGenericControl("script"); if (language.Length > 0) { script.Attributes["type"] = "text/" + language; } // Convert the path into one that is useble for the client and sets as value for the src attribute script.Attributes["src"] = ResolveUrl(path); // Insert to the script object to the collection Header.Controls.Add(script); // Insert the path as key in the Dictionary, it means the script path is registered. _registeredScripts[path] = "true"; return true; } /// <summary> /// Determines if the client startup script is registered with the <see cref="EditPage"/> object. /// </summary> /// <param name="path">The path to the script file</param> /// <returns>True if the script file is registered; otherwise, false.</returns> public bool IsScriptFileRegistered(string path) { return _registeredScripts[path] != null; } } }
Inheritance Hierarchy
System..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.Page
EPiServer..::.PageBase
EPiServer..::.SimplePage
EPiServer..::.EditPage
EPiServer..::.TemplatePage
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.Page
EPiServer..::.PageBase
EPiServer..::.SimplePage
EPiServer..::.EditPage
EPiServer..::.TemplatePage