ContentPlaceHolderDesigner.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / ContentPlaceHolderDesigner.cs / 1 / ContentPlaceHolderDesigner.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.Design.WebControls { 
 
    using System.Diagnostics;
 
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.ComponentModel.Design; 
    using System.Design;
    using System.Drawing; 
    using System.Drawing.Imaging; 
    using System.Globalization;
    using System.IO; 
    using System.Text;
    using System.Web.UI.WebControls;

 
    /// 
    ///  
    ///     
    ///       Provides design-time support for the 
    ///       web control. 
    ///    
    /// 
    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
    public class ContentPlaceHolderDesigner : ControlDesigner { 

        private string _content; 
        private const string designtimeHTML = 
        @"
 {0}
"; public override bool AllowResize { get { return true; } } private string CreateDesignTimeHTML() { StringBuilder sb = new StringBuilder(1024); Font defaultFont = SystemFonts.CaptionFont; Color foreColor = SystemColors.ControlText; Color backColor = SystemColors.Control; string caption = Component.GetType().Name + " - " + Component.Site.Name; sb.Append(String.Format(CultureInfo.InvariantCulture, designtimeHTML, caption, DesignerRegion.DesignerRegionAttributeName, defaultFont.SizeInPoints, ColorTranslator.ToHtml(foreColor), ColorTranslator.ToHtml(backColor))); return sb.ToString(); } public override string GetDesignTimeHtml() { IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (!(host.RootComponent is MasterPage)) { throw new InvalidOperationException(SR.GetString(SR.ContentPlaceHolder_Invalid_RootComponent)); } return base.GetDesignTimeHtml(); } /// public override string GetDesignTimeHtml(DesignerRegionCollection regions) { IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (!(host.RootComponent is MasterPage)) { throw new InvalidOperationException(SR.GetString(SR.ContentPlaceHolder_Invalid_RootComponent)); } // Create the single editable region regions.Add(new EditableDesignerRegion(this, "Content")); return CreateDesignTimeHTML(); } /// public override string GetEditableDesignerRegionContent(EditableDesignerRegion region) { if (_content == null) { _content = Tag.GetContent(); } return _content != null ? _content.Trim() : string.Empty; } public override string GetPersistenceContent() { return _content; } /// public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { _content = content; Tag.SetDirty(true); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK